Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions apps/comments/appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ function () {
$activityManager->registerExtension(function () {
$application = new \OCP\AppFramework\App('comments');
/** @var \OCA\Comments\Activity\Extension $extension */
$extension = $application->getContainer()->query('OCA\Comments\Activity\Extension');
$extension = $application->getContainer()->query(\OCA\Comments\Activity\Extension::class);
return $extension;
});

$managerListener = function (\OCP\Comments\CommentsEvent $event) {
$application = new \OCP\AppFramework\App('comments');
/** @var \OCA\Comments\Activity\Listener $listener */
$listener = $application->getContainer()->query('OCA\Comments\Activity\Listener');
$listener = $application->getContainer()->query(\OCA\Comments\Activity\Listener::class);
$listener->commentEvent($event);
};

Expand Down
4 changes: 1 addition & 3 deletions apps/comments/lib/Dav/CommentNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ public function __construct(
$this->logger = $logger;

$methods = \get_class_methods($this->comment);
$methods = \array_filter($methods, function ($name) {
return \strpos($name, 'get') === 0;
});
$methods = \array_filter($methods, fn ($name) => \strpos($name, 'get') === 0);
foreach ($methods as $getter) {
$name = '{'.self::NS_OWNCLOUD.'}' . \lcfirst(\substr($getter, 3));
$this->properties[$name] = $getter;
Expand Down
5 changes: 2 additions & 3 deletions apps/comments/lib/Dav/CommentsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ class CommentsPlugin extends ServerPlugin {
/** @var ICommentsManager */
protected $commentsManager;

/** @var \Sabre\DAV\Server $server */
private $server;
private ?\Sabre\DAV\Server $server = null;

/** @var \OCP\IUserSession */
protected $userSession;
Expand Down Expand Up @@ -222,7 +221,7 @@ public function onReport($reportName, $report, $uri) {
*/
private function createComment($objectType, $objectId, $data, $contentType = 'application/json') {
if (\explode(';', $contentType)[0] === 'application/json') {
$data = \json_decode($data, true);
$data = \json_decode($data, true, 512, JSON_THROW_ON_ERROR);
} else {
throw new UnsupportedMediaType();
}
Expand Down
4 changes: 2 additions & 2 deletions apps/comments/lib/Dav/EntityCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public function __construct(
) {
parent::__construct($commentsManager, $userManager, $userSession, $dispatcher, $logger);
foreach (['id', 'name'] as $property) {
$$property = \trim($$property);
if (empty($$property) || !\is_string($$property)) {
${$property} = \trim(${$property});
if (empty(${$property}) || !\is_string(${$property})) {
throw new \InvalidArgumentException('"' . $property . '" parameter must be non-empty string');
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/comments/lib/Dav/RootCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

class RootCollection implements ICollection {
/** @var EntityTypeCollection[]|null */
private $entityTypeCollections;
private ?array $entityTypeCollections = null;

/** @var ICommentsManager */
protected $commentsManager;
Expand Down
13 changes: 5 additions & 8 deletions apps/comments/tests/unit/ActivityListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,27 @@
class ActivityListenerTest extends \Test\TestCase {
use UserTrait;

/**
* @var Listener
*/
private $listener;
private \OCA\Comments\Activity\Listener $listener;

/**
* @var IUserMountCache
*/
private $userMountCache;
private \PHPUnit\Framework\MockObject\MockObject $userMountCache;

/**
* @var IRootFolder
*/
private $rootFolder;
private \PHPUnit\Framework\MockObject\MockObject $rootFolder;

/**
* @var IUserSession
*/
private $userSession;
private \PHPUnit\Framework\MockObject\MockObject $userSession;

/**
* @var IManager
*/
private $activityManager;
private \PHPUnit\Framework\MockObject\MockObject $activityManager;

protected function setUp(): void {
parent::setUp();
Expand Down
30 changes: 15 additions & 15 deletions apps/comments/tests/unit/Dav/CommentsNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class CommentsNodeTest extends \Test\TestCase {
public function setUp(): void {
parent::setUp();

$this->commentsManager = $this->createMock('\OCP\Comments\ICommentsManager');
$this->comment = $this->createMock('\OCP\Comments\IComment');
$this->userManager = $this->createMock('\OCP\IUserManager');
$this->userSession = $this->createMock('\OCP\IUserSession');
$this->logger = $this->createMock('\OCP\ILogger');
$this->commentsManager = $this->createMock('\\' . \OCP\Comments\ICommentsManager::class);
$this->comment = $this->createMock('\\' . \OCP\Comments\IComment::class);
$this->userManager = $this->createMock('\\' . \OCP\IUserManager::class);
$this->userSession = $this->createMock('\\' . \OCP\IUserSession::class);
$this->logger = $this->createMock('\\' . \OCP\ILogger::class);

$this->node = new CommentNode(
$this->commentsManager,
Expand All @@ -54,7 +54,7 @@ public function setUp(): void {
}

public function testDelete() {
$user = $this->createMock('\OCP\IUser');
$user = $this->createMock('\\' . \OCP\IUser::class);

$user->expects($this->once())
->method('getUID')
Expand Down Expand Up @@ -88,7 +88,7 @@ public function testDelete() {
public function testDeleteForbidden() {
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);

$user = $this->createMock('\OCP\IUser');
$user = $this->createMock('\\' . \OCP\IUser::class);

$user->expects($this->once())
->method('getUID')
Expand Down Expand Up @@ -139,7 +139,7 @@ public function testGetLastModified() {
public function testUpdateComment() {
$msg = 'Hello Earth';

$user = $this->createMock('\OCP\IUser');
$user = $this->createMock('\\' . \OCP\IUser::class);

$user->expects($this->once())
->method('getUID')
Expand Down Expand Up @@ -176,7 +176,7 @@ public function testUpdateCommentLogException() {

$msg = null;

$user = $this->createMock('\OCP\IUser');
$user = $this->createMock('\\' . \OCP\IUser::class);

$user->expects($this->once())
->method('getUID')
Expand Down Expand Up @@ -214,7 +214,7 @@ public function testUpdateCommentMessageTooLongException() {
$this->expectException(\Sabre\DAV\Exception\BadRequest::class);
$this->expectExceptionMessage('Message exceeds allowed character limit of');

$user = $this->createMock('\OCP\IUser');
$user = $this->createMock('\\' . \OCP\IUser::class);

$user->expects($this->once())
->method('getUID')
Expand Down Expand Up @@ -253,7 +253,7 @@ public function testUpdateForbiddenByUser() {

$msg = 'HaXX0r';

$user = $this->createMock('\OCP\IUser');
$user = $this->createMock('\\' . \OCP\IUser::class);

$user->expects($this->once())
->method('getUID')
Expand Down Expand Up @@ -287,7 +287,7 @@ public function testUpdateForbiddenByType() {

$msg = 'HaXX0r';

$user = $this->createMock('\OCP\IUser');
$user = $this->createMock('\\' . \OCP\IUser::class);

$user->expects($this->never())
->method('getUID');
Expand Down Expand Up @@ -334,7 +334,7 @@ public function testUpdateForbiddenByNotLoggedIn() {
}

public function testPropPatch() {
$propPatch = $this->getMockBuilder('Sabre\DAV\PropPatch')
$propPatch = $this->getMockBuilder(\Sabre\DAV\PropPatch::class)
->disableOriginalConstructor()
->getMock();

Expand Down Expand Up @@ -412,7 +412,7 @@ public function testGetProperties() {
->method('getObjectId')
->will($this->returnValue($expected[$ns . 'objectId']));

$user = $this->getMockBuilder('\OCP\IUser')
$user = $this->getMockBuilder('\\' . \OCP\IUser::class)
->disableOriginalConstructor()
->getMock();
$user->expects($this->once())
Expand Down Expand Up @@ -463,7 +463,7 @@ public function testGetPropertiesUnreadProperty($creationDT, $readDT, $expected)

$this->userSession->expects($this->once())
->method('getUser')
->will($this->returnValue($this->createMock('\OCP\IUser')));
->will($this->returnValue($this->createMock('\\' . \OCP\IUser::class)));

$properties = $this->node->getProperties(null);

Expand Down
Loading