Browse Source

Add a stub for the comments manager to clarify it's defined methods

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/4483/head
Vincent Petry 5 years ago
committed by Joas Schilling
parent
commit
3caa7ca676
No known key found for this signature in database GPG Key ID: 7076EA9751AACDDA
  1. 5
      lib/Chat/AutoComplete/Sorter.php
  2. 2
      lib/Chat/ChatManager.php
  3. 1
      lib/Chat/Parser/UserMention.php
  4. 5
      lib/Manager.php
  5. 3
      lib/Notification/Notifier.php
  6. 3
      psalm.xml
  7. 48
      tests/psalm-baseline.xml
  8. 6
      tests/stubs/oc_comments_manager.php

5
lib/Chat/AutoComplete/Sorter.php

@ -23,15 +23,16 @@ declare(strict_types=1);
namespace OCA\Talk\Chat\AutoComplete;
use OCP\Comments\ICommentsManager;
use OCA\Talk\Chat\CommentsManager;
use OCP\Collaboration\AutoComplete\ISorter;
use OCP\Comments\ICommentsManager;
class Sorter implements ISorter {
/** @var ICommentsManager */
protected $commentsManager;
public function __construct(ICommentsManager $commentsManager) {
public function __construct(CommentsManager $commentsManager) {
$this->commentsManager = $commentsManager;
}

2
lib/Chat/ChatManager.php

@ -59,7 +59,7 @@ class ChatManager {
public const MAX_CHAT_LENGTH = 32000;
/** @var CommentsManager|ICommentsManager */
/** @var ICommentsManager */
private $commentsManager;
/** @var IEventDispatcher */
private $dispatcher;

1
lib/Chat/Parser/UserMention.php

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace OCA\Talk\Chat\Parser;
use OCA\Talk\Chat\CommentsManager;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\GuestManager;
use OCA\Talk\Model\Message;

5
lib/Manager.php

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace OCA\Talk;
use OCA\Talk\Chat\Changelog;
use OCA\Talk\Chat\CommentsManager;
use OCA\Talk\Events\CreateRoomTokenEvent;
use OCA\Talk\Events\RoomEvent;
@ -31,6 +30,7 @@ use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Exceptions\RoomNotFoundException;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Comments\IComment;
use OCP\Comments\ICommentsManager;
use OCP\Comments\NotFoundException;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\EventDispatcher\IEventDispatcher;
@ -54,7 +54,7 @@ class Manager {
private $secureRandom;
/** @var IUserManager */
private $userManager;
/** @var CommentsManager */
/** @var ICommentsManager */
private $commentsManager;
/** @var TalkSession */
private $talkSession;
@ -192,6 +192,7 @@ class Manager {
}
public function createCommentObject(array $row): ?IComment {
/** @psalm-suppress UndefinedInterfaceMethod */
return $this->commentsManager->getCommentFromData([
'id' => $row['comment_id'],
'parent_id' => $row['comment_parent_id'],

3
lib/Notification/Notifier.php

@ -32,6 +32,7 @@ use OCA\Talk\GuestManager;
use OCA\Talk\Manager;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCP\Comments\ICommentsManager;
use OCP\Comments\NotFoundException;
use OCP\IL10N;
use OCP\IURLGenerator;
@ -66,7 +67,7 @@ class Notifier implements INotifier {
protected $manager;
/** @var INotificationManager */
protected $notificationManager;
/** @var CommentsManager */
/** @var ICommentsManager */
protected $commentManager;
/** @var MessageParser */
protected $messageParser;

3
psalm.xml

@ -32,4 +32,7 @@
</errorLevel>
</UndefinedDocblockClass>
</issueHandlers>
<stubs>
<file name="tests/stubs/oc_comments_manager.php" />
</stubs>
</psalm>

48
tests/psalm-baseline.xml

@ -14,47 +14,10 @@
<code>SchemaWrapper</code>
</UndefinedClass>
</file>
<file src="lib/Chat/AutoComplete/Sorter.php">
<MissingDependency occurrences="3">
<code>$this-&gt;commentsManager</code>
<code>CommentsManager</code>
<code>CommentsManager</code>
</MissingDependency>
</file>
<file src="lib/Chat/ChatManager.php">
<MissingDependency occurrences="18">
<code>$this-&gt;commentsManager</code>
<code>$this-&gt;commentsManager</code>
<code>$this-&gt;commentsManager</code>
<code>$this-&gt;commentsManager</code>
<code>$this-&gt;commentsManager</code>
<code>$this-&gt;commentsManager</code>
<code>$this-&gt;commentsManager</code>
<code>$this-&gt;commentsManager</code>
<code>$this-&gt;commentsManager</code>
<code>$this-&gt;commentsManager</code>
<code>$this-&gt;commentsManager</code>
<code>$this-&gt;commentsManager</code>
<code>$this-&gt;commentsManager</code>
<code>$this-&gt;commentsManager</code>
<code>$this-&gt;commentsManager</code>
<code>$this-&gt;commentsManager</code>
<code>CommentsManager</code>
<code>CommentsManager|ICommentsManager</code>
</MissingDependency>
<UndefinedClass occurrences="1">
<code>NullCache</code>
</UndefinedClass>
<UndefinedInterfaceMethod occurrences="3">
<code>getLastCommentBeforeDate</code>
<code>getNumberOfCommentsForObjectSinceComment</code>
<code>searchForObjects</code>
</UndefinedInterfaceMethod>
</file>
<file src="lib/Chat/CommentsManager.php">
<UndefinedClass occurrences="1">
<code>Manager</code>
</UndefinedClass>
</file>
<file src="lib/Chat/MessageParser.php">
<UndefinedVariable occurrences="1">
@ -293,12 +256,6 @@
</file>
<file src="lib/Manager.php">
<InvalidArgument occurrences="4"/>
<MissingDependency occurrences="4">
<code>$this-&gt;commentsManager</code>
<code>$this-&gt;commentsManager</code>
<code>CommentsManager</code>
<code>CommentsManager</code>
</MissingDependency>
</file>
<file src="lib/MatterbridgeManager.php">
<UndefinedClass occurrences="4">
@ -516,10 +473,7 @@
<code>$this-&gt;rooms</code>
<code>$this-&gt;rooms</code>
</InvalidPropertyAssignmentValue>
<MissingDependency occurrences="4">
<code>$this-&gt;commentManager</code>
<code>CommentsManager</code>
<code>CommentsManager</code>
<MissingDependency occurrences="1">
<code>ShareNotFound</code>
</MissingDependency>
</file>

6
tests/stubs/oc_comments_manager.php

@ -0,0 +1,6 @@
<?php
namespace OC\Comments {
class Manager implements \OCP\Comments\ICommentsManager {
}
}
Loading…
Cancel
Save