Skip to content

Commit 6a6970e

Browse files
committed
chore: migrate code base to php7.4 standard using rector
1 parent 83c0f18 commit 6a6970e

1,214 files changed

Lines changed: 7502 additions & 10840 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/comments/appinfo/app.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ function () {
3939
$activityManager->registerExtension(function () {
4040
$application = new \OCP\AppFramework\App('comments');
4141
/** @var \OCA\Comments\Activity\Extension $extension */
42-
$extension = $application->getContainer()->query('OCA\Comments\Activity\Extension');
42+
$extension = $application->getContainer()->query(\OCA\Comments\Activity\Extension::class);
4343
return $extension;
4444
});
4545

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

apps/comments/lib/Dav/CommentNode.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ public function __construct(
7979
$this->logger = $logger;
8080

8181
$methods = \get_class_methods($this->comment);
82-
$methods = \array_filter($methods, function ($name) {
83-
return \strpos($name, 'get') === 0;
84-
});
82+
$methods = \array_filter($methods, fn ($name) => \strpos($name, 'get') === 0);
8583
foreach ($methods as $getter) {
8684
$name = '{'.self::NS_OWNCLOUD.'}' . \lcfirst(\substr($getter, 3));
8785
$this->properties[$name] = $getter;

apps/comments/lib/Dav/CommentsPlugin.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ class CommentsPlugin extends ServerPlugin {
5353
/** @var ICommentsManager */
5454
protected $commentsManager;
5555

56-
/** @var \Sabre\DAV\Server $server */
57-
private $server;
56+
private ?\Sabre\DAV\Server $server = null;
5857

5958
/** @var \OCP\IUserSession */
6059
protected $userSession;
@@ -222,7 +221,7 @@ public function onReport($reportName, $report, $uri) {
222221
*/
223222
private function createComment($objectType, $objectId, $data, $contentType = 'application/json') {
224223
if (\explode(';', $contentType)[0] === 'application/json') {
225-
$data = \json_decode($data, true);
224+
$data = \json_decode($data, true, 512, JSON_THROW_ON_ERROR);
226225
} else {
227226
throw new UnsupportedMediaType();
228227
}

apps/comments/lib/Dav/EntityCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ public function __construct(
6767
) {
6868
parent::__construct($commentsManager, $userManager, $userSession, $dispatcher, $logger);
6969
foreach (['id', 'name'] as $property) {
70-
$$property = \trim($$property);
71-
if (empty($$property) || !\is_string($$property)) {
70+
${$property} = \trim(${$property});
71+
if (empty(${$property}) || !\is_string(${$property})) {
7272
throw new \InvalidArgumentException('"' . $property . '" parameter must be non-empty string');
7373
}
7474
}

apps/comments/lib/Dav/RootCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
class RootCollection implements ICollection {
3838
/** @var EntityTypeCollection[]|null */
39-
private $entityTypeCollections;
39+
private ?array $entityTypeCollections = null;
4040

4141
/** @var ICommentsManager */
4242
protected $commentsManager;

apps/comments/tests/unit/ActivityListenerTest.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,27 @@
4545
class ActivityListenerTest extends \Test\TestCase {
4646
use UserTrait;
4747

48-
/**
49-
* @var Listener
50-
*/
51-
private $listener;
48+
private \OCA\Comments\Activity\Listener $listener;
5249

5350
/**
5451
* @var IUserMountCache
5552
*/
56-
private $userMountCache;
53+
private \PHPUnit\Framework\MockObject\MockObject $userMountCache;
5754

5855
/**
5956
* @var IRootFolder
6057
*/
61-
private $rootFolder;
58+
private \PHPUnit\Framework\MockObject\MockObject $rootFolder;
6259

6360
/**
6461
* @var IUserSession
6562
*/
66-
private $userSession;
63+
private \PHPUnit\Framework\MockObject\MockObject $userSession;
6764

6865
/**
6966
* @var IManager
7067
*/
71-
private $activityManager;
68+
private \PHPUnit\Framework\MockObject\MockObject $activityManager;
7269

7370
protected function setUp(): void {
7471
parent::setUp();

apps/comments/tests/unit/Dav/CommentsNodeTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ class CommentsNodeTest extends \Test\TestCase {
3838
public function setUp(): void {
3939
parent::setUp();
4040

41-
$this->commentsManager = $this->createMock('\OCP\Comments\ICommentsManager');
42-
$this->comment = $this->createMock('\OCP\Comments\IComment');
43-
$this->userManager = $this->createMock('\OCP\IUserManager');
44-
$this->userSession = $this->createMock('\OCP\IUserSession');
45-
$this->logger = $this->createMock('\OCP\ILogger');
41+
$this->commentsManager = $this->createMock('\\' . \OCP\Comments\ICommentsManager::class);
42+
$this->comment = $this->createMock('\\' . \OCP\Comments\IComment::class);
43+
$this->userManager = $this->createMock('\\' . \OCP\IUserManager::class);
44+
$this->userSession = $this->createMock('\\' . \OCP\IUserSession::class);
45+
$this->logger = $this->createMock('\\' . \OCP\ILogger::class);
4646

4747
$this->node = new CommentNode(
4848
$this->commentsManager,
@@ -54,7 +54,7 @@ public function setUp(): void {
5454
}
5555

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

5959
$user->expects($this->once())
6060
->method('getUID')
@@ -88,7 +88,7 @@ public function testDelete() {
8888
public function testDeleteForbidden() {
8989
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
9090

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

9393
$user->expects($this->once())
9494
->method('getUID')
@@ -139,7 +139,7 @@ public function testGetLastModified() {
139139
public function testUpdateComment() {
140140
$msg = 'Hello Earth';
141141

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

144144
$user->expects($this->once())
145145
->method('getUID')
@@ -176,7 +176,7 @@ public function testUpdateCommentLogException() {
176176

177177
$msg = null;
178178

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

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

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

219219
$user->expects($this->once())
220220
->method('getUID')
@@ -253,7 +253,7 @@ public function testUpdateForbiddenByUser() {
253253

254254
$msg = 'HaXX0r';
255255

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

258258
$user->expects($this->once())
259259
->method('getUID')
@@ -287,7 +287,7 @@ public function testUpdateForbiddenByType() {
287287

288288
$msg = 'HaXX0r';
289289

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

292292
$user->expects($this->never())
293293
->method('getUID');
@@ -334,7 +334,7 @@ public function testUpdateForbiddenByNotLoggedIn() {
334334
}
335335

336336
public function testPropPatch() {
337-
$propPatch = $this->getMockBuilder('Sabre\DAV\PropPatch')
337+
$propPatch = $this->getMockBuilder(\Sabre\DAV\PropPatch::class)
338338
->disableOriginalConstructor()
339339
->getMock();
340340

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

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

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

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

0 commit comments

Comments
 (0)