Skip to content

Commit

Permalink
refactor: Replace class strings with ::class constants
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Sep 15, 2024
1 parent 4281ce6 commit 275a8ce
Show file tree
Hide file tree
Showing 224 changed files with 1,079 additions and 1,079 deletions.
2 changes: 1 addition & 1 deletion apps/admin_audit/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,6 @@ private function versionsHooks(IAuditLogger $logger): void {
private function trashbinHooks(IAuditLogger $logger): void {
$trashActions = new Trashbin($logger);
Util::connectHook('\OCP\Trashbin', 'preDelete', $trashActions, 'delete');
Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', $trashActions, 'restore');
Util::connectHook(\OCA\Files_Trashbin\Trashbin::class, 'post_restore', $trashActions, 'restore');
}
}
12 changes: 6 additions & 6 deletions apps/comments/tests/Unit/AppInfo/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public function test() {
$c = $app->getContainer();

$services = [
'OCA\Comments\Controller\NotificationsController',
'OCA\Comments\Activity\Filter',
'OCA\Comments\Activity\Listener',
'OCA\Comments\Activity\Provider',
'OCA\Comments\Activity\Setting',
'OCA\Comments\Notification\Listener',
\OCA\Comments\Controller\NotificationsController::class,
\OCA\Comments\Activity\Filter::class,
\OCA\Comments\Activity\Listener::class,
\OCA\Comments\Activity\Provider::class,
\OCA\Comments\Activity\Setting::class,
\OCA\Comments\Notification\Listener::class,
Notifier::class,
];

Expand Down
2 changes: 1 addition & 1 deletion apps/comments/tests/Unit/Notification/ListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function testEvaluate($eventType, $notificationMethod) {
->willReturn($notification);
$this->notificationManager->expects($this->exactly(6))
->method($notificationMethod)
->with($this->isInstanceOf('\OCP\Notification\INotification'));
->with($this->isInstanceOf(\OCP\Notification\INotification::class));

$this->userManager->expects($this->exactly(6))
->method('userExists')
Expand Down
12 changes: 6 additions & 6 deletions apps/dav/lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ class CalendarSearchReport implements XmlDeserializable {
*/
public static function xmlDeserialize(Reader $reader) {
$elems = $reader->parseInnerTree([
'{http://nextcloud.com/ns}comp-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter',
'{http://nextcloud.com/ns}prop-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter',
'{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter',
'{http://nextcloud.com/ns}search-term' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter',
'{http://nextcloud.com/ns}limit' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter',
'{http://nextcloud.com/ns}offset' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter',
'{http://nextcloud.com/ns}comp-filter' => \OCA\DAV\CalDAV\Search\Xml\Filter\CompFilter::class,
'{http://nextcloud.com/ns}prop-filter' => \OCA\DAV\CalDAV\Search\Xml\Filter\PropFilter::class,
'{http://nextcloud.com/ns}param-filter' => \OCA\DAV\CalDAV\Search\Xml\Filter\ParamFilter::class,
'{http://nextcloud.com/ns}search-term' => \OCA\DAV\CalDAV\Search\Xml\Filter\SearchTermFilter::class,
'{http://nextcloud.com/ns}limit' => \OCA\DAV\CalDAV\Search\Xml\Filter\LimitFilter::class,
'{http://nextcloud.com/ns}offset' => \OCA\DAV\CalDAV\Search\Xml\Filter\OffsetFilter::class,
'{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue',
]);

Expand Down
2 changes: 1 addition & 1 deletion apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function setUp(): void {
parent::setUp();

$db = \OC::$server->getDatabaseConnection();
$this->principal = $this->createMock('OCA\DAV\Connector\Sabre\Principal');
$this->principal = $this->createMock(\OCA\DAV\Connector\Sabre\Principal::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->random = \OC::$server->getSecureRandom();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class CalendarSearchReportTest extends TestCase {
private $elementMap = [
'{http://nextcloud.com/ns}calendar-search' =>
'OCA\\DAV\\CalDAV\\Search\\Xml\\Request\\CalendarSearchReport',
\OCA\DAV\CalDAV\Search\Xml\Request\CalendarSearchReport::class,
];

public function testFoo(): void {
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testInitialize(): void {

$this->assertEquals(
$server->xml->elementMap['{http://nextcloud.com/ns}calendar-search'],
'OCA\\DAV\\CalDAV\\Search\\Xml\\Request\\CalendarSearchReport'
\OCA\DAV\CalDAV\Search\Xml\Request\CalendarSearchReport::class
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function setUp(): void {

public function nodeProvider() {
$mocks = [];
foreach (['\OCA\DAV\Connector\Sabre\File', '\OCA\DAV\Connector\Sabre\Directory', '\Sabre\DAV\INode'] as $class) {
foreach ([\OCA\DAV\Connector\Sabre\File::class, \OCA\DAV\Connector\Sabre\Directory::class, '\Sabre\DAV\INode'] as $class) {
$mocks[] = $this->getMockBuilder($class)
->disableOriginalConstructor()
->getMock();
Expand Down
12 changes: 6 additions & 6 deletions apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class DirectoryTest extends \Test\TestCase {
protected function setUp(): void {
parent::setUp();

$this->view = $this->createMock('OC\Files\View');
$this->info = $this->createMock('OC\Files\FileInfo');
$this->view = $this->createMock(\OC\Files\View::class);
$this->info = $this->createMock(\OC\Files\FileInfo::class);
$this->info->method('isReadable')
->willReturn(true);
$this->info->method('getType')
Expand Down Expand Up @@ -283,8 +283,8 @@ public function testGetQuotaInfoUnlimited(): void {
$storage->expects($this->any())
->method('instanceOfStorage')
->willReturnMap([
'\OCA\Files_Sharing\SharedStorage' => false,
'\OC\Files\Storage\Wrapper\Quota' => false,
\OCA\Files_Sharing\SharedStorage::class => false,
\OC\Files\Storage\Wrapper\Quota::class => false,
]);

$storage->expects($this->once())
Expand Down Expand Up @@ -334,8 +334,8 @@ public function testGetQuotaInfoSpecific(): void {
$storage->expects($this->any())
->method('instanceOfStorage')
->willReturnMap([
['\OCA\Files_Sharing\SharedStorage', false],
['\OC\Files\Storage\Wrapper\Quota', true],
[\OCA\Files_Sharing\SharedStorage::class, false],
[\OC\Files\Storage\Wrapper\Quota::class, true],
]);

$storage->expects($this->once())
Expand Down
12 changes: 6 additions & 6 deletions apps/dav/tests/unit/Connector/Sabre/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,27 +109,27 @@ public function fopenFailuresProvider() {
],
[
new \OCP\Files\EntityTooLargeException(),
'OCA\DAV\Connector\Sabre\Exception\EntityTooLarge'
\OCA\DAV\Connector\Sabre\Exception\EntityTooLarge::class
],
[
new \OCP\Files\InvalidContentException(),
'OCA\DAV\Connector\Sabre\Exception\UnsupportedMediaType'
\OCA\DAV\Connector\Sabre\Exception\UnsupportedMediaType::class
],
[
new \OCP\Files\InvalidPathException(),
'Sabre\DAV\Exception\Forbidden'
],
[
new \OCP\Files\ForbiddenException('', true),
'OCA\DAV\Connector\Sabre\Exception\Forbidden'
\OCA\DAV\Connector\Sabre\Exception\Forbidden::class
],
[
new \OCP\Files\LockNotAcquiredException('/test.txt', 1),
'OCA\DAV\Connector\Sabre\Exception\FileLocked'
\OCA\DAV\Connector\Sabre\Exception\FileLocked::class
],
[
new \OCP\Lock\LockedException('/test.txt'),
'OCA\DAV\Connector\Sabre\Exception\FileLocked'
\OCA\DAV\Connector\Sabre\Exception\FileLocked::class
],
[
new \OCP\Encryption\Exceptions\GenericEncryptionException(),
Expand Down Expand Up @@ -454,7 +454,7 @@ public function testPutSingleFileCancelPreHook(): void {
\OCP\Util::connectHook(
Filesystem::CLASSNAME,
Filesystem::signal_create,
'\Test\HookHelper',
\Test\HookHelper::class,
'cancellingCallback'
);

Expand Down
12 changes: 6 additions & 6 deletions apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private function createTestNode($class, $path = '/dummypath') {

public function testGetPropertiesForFile(): void {
/** @var \OCA\DAV\Connector\Sabre\File | \PHPUnit\Framework\MockObject\MockObject $node */
$node = $this->createTestNode('\OCA\DAV\Connector\Sabre\File');
$node = $this->createTestNode(\OCA\DAV\Connector\Sabre\File::class);

$propFind = new PropFind(
'/dummyPath',
Expand Down Expand Up @@ -181,7 +181,7 @@ public function testGetPropertiesForFile(): void {

public function testGetPropertiesStorageNotAvailable(): void {
/** @var \OCA\DAV\Connector\Sabre\File | \PHPUnit\Framework\MockObject\MockObject $node */
$node = $this->createTestNode('\OCA\DAV\Connector\Sabre\File');
$node = $this->createTestNode(\OCA\DAV\Connector\Sabre\File::class);

$propFind = new PropFind(
'/dummyPath',
Expand Down Expand Up @@ -228,7 +228,7 @@ public function testGetPublicPermissions(): void {
);

/** @var \OCA\DAV\Connector\Sabre\File | \PHPUnit\Framework\MockObject\MockObject $node */
$node = $this->createTestNode('\OCA\DAV\Connector\Sabre\File');
$node = $this->createTestNode(\OCA\DAV\Connector\Sabre\File::class);
$node->expects($this->any())
->method('getDavPermissions')
->willReturn('DWCKMSR');
Expand All @@ -243,7 +243,7 @@ public function testGetPublicPermissions(): void {

public function testGetPropertiesForDirectory(): void {
/** @var \OCA\DAV\Connector\Sabre\Directory | \PHPUnit\Framework\MockObject\MockObject $node */
$node = $this->createTestNode('\OCA\DAV\Connector\Sabre\Directory');
$node = $this->createTestNode(\OCA\DAV\Connector\Sabre\Directory::class);

$propFind = new PropFind(
'/dummyPath',
Expand Down Expand Up @@ -345,7 +345,7 @@ public function testGetPropertiesWhenNoPermission(): void {
}

public function testUpdateProps(): void {
$node = $this->createTestNode('\OCA\DAV\Connector\Sabre\File');
$node = $this->createTestNode(\OCA\DAV\Connector\Sabre\File::class);

$testDate = 'Fri, 13 Feb 2015 00:01:02 GMT';
$testCreationDate = '2007-08-31T16:47+00:00';
Expand Down Expand Up @@ -615,7 +615,7 @@ public function testDownloadHeaders($isClumsyAgent, $contentDispositionHeader):

public function testHasPreview(): void {
/** @var \OCA\DAV\Connector\Sabre\Directory | \PHPUnit\Framework\MockObject\MockObject $node */
$node = $this->createTestNode('\OCA\DAV\Connector\Sabre\Directory');
$node = $this->createTestNode(\OCA\DAV\Connector\Sabre\Directory::class);

$propFind = new PropFind(
'/dummyPath',
Expand Down
8 changes: 4 additions & 4 deletions apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ public function testFindNodesByFileIdsRoot(): void {
$result = $this->plugin->findNodesByFileIds($reportTargetNode, ['111', '222']);

$this->assertCount(2, $result);
$this->assertInstanceOf('\OCA\DAV\Connector\Sabre\Directory', $result[0]);
$this->assertInstanceOf(\OCA\DAV\Connector\Sabre\Directory::class, $result[0]);
$this->assertEquals('first node', $result[0]->getName());
$this->assertInstanceOf('\OCA\DAV\Connector\Sabre\File', $result[1]);
$this->assertInstanceOf(\OCA\DAV\Connector\Sabre\File::class, $result[1]);
$this->assertEquals('second node', $result[1]->getName());
}

Expand Down Expand Up @@ -346,9 +346,9 @@ public function testFindNodesByFileIdsSubDir(): void {
$result = $this->plugin->findNodesByFileIds($reportTargetNode, ['111', '222']);

$this->assertCount(2, $result);
$this->assertInstanceOf('\OCA\DAV\Connector\Sabre\Directory', $result[0]);
$this->assertInstanceOf(\OCA\DAV\Connector\Sabre\Directory::class, $result[0]);
$this->assertEquals('first node', $result[0]->getName());
$this->assertInstanceOf('\OCA\DAV\Connector\Sabre\File', $result[1]);
$this->assertInstanceOf(\OCA\DAV\Connector\Sabre\File::class, $result[1]);
$this->assertEquals('second node', $result[1]->getName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testBasicUpload(): void {
$mount->getStorage()->unlink($mount->getInternalPath($internalPath));

// cache entry still exists
$this->assertInstanceOf('\OCP\Files\FileInfo', $view->getFileInfo('foo.txt'));
$this->assertInstanceOf(\OCP\Files\FileInfo::class, $view->getFileInfo('foo.txt'));

$response = $this->request($view, $user, 'pass', 'DELETE', '/foo.txt');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class EncryptionMasterKeyUploadTest extends UploadTest {
protected function setupUser($name, $password) {
$this->createUser($name, $password);
$tmpFolder = \OC::$server->getTempManager()->getTemporaryFolder();
$this->registerMount($name, '\OC\Files\Storage\Local', '/' . $name, ['datadir' => $tmpFolder]);
$this->registerMount($name, \OC\Files\Storage\Local::class, '/' . $name, ['datadir' => $tmpFolder]);
// we use the master key
\OC::$server->getConfig()->setAppValue('encryption', 'useMasterKey', '1');
$this->setupForUser($name, $password);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class EncryptionUploadTest extends UploadTest {
protected function setupUser($name, $password) {
$this->createUser($name, $password);
$tmpFolder = \OC::$server->getTempManager()->getTemporaryFolder();
$this->registerMount($name, '\OC\Files\Storage\Local', '/' . $name, ['datadir' => $tmpFolder]);
$this->registerMount($name, \OC\Files\Storage\Local::class, '/' . $name, ['datadir' => $tmpFolder]);
// we use per-user keys
\OC::$server->getConfig()->setAppValue('encryption', 'useMasterKey', '0');
$this->setupForUser($name, $password);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function setUp(): void {
protected function setupUser($name, $password) {
$this->createUser($name, $password);
$tmpFolder = \OC::$server->getTempManager()->getTemporaryFolder();
$this->registerMount($name, '\OC\Files\Storage\Local', '/' . $name, ['datadir' => $tmpFolder]);
$this->registerMount($name, \OC\Files\Storage\Local::class, '/' . $name, ['datadir' => $tmpFolder]);
$this->loginAsUser($name);
return new View('/' . $name . '/files');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testBasicUpload(): void {
$this->assertEquals('asd', $view->file_get_contents('foo.txt'));

$info = $view->getFileInfo('foo.txt');
$this->assertInstanceOf('\OC\Files\FileInfo', $info);
$this->assertInstanceOf(\OC\Files\FileInfo::class, $info);
$this->assertEquals(3, $info->getSize());
}

Expand All @@ -46,7 +46,7 @@ public function testUploadOverWrite(): void {
$this->assertEquals('asd', $view->file_get_contents('foo.txt'));

$info = $view->getFileInfo('foo.txt');
$this->assertInstanceOf('\OC\Files\FileInfo', $info);
$this->assertInstanceOf(\OC\Files\FileInfo::class, $info);
$this->assertEquals(3, $info->getSize());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function testEnable(): void {
);

$response = $this->controller->enable();
$this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $response);
$this->assertInstanceOf(\OCP\AppFramework\Http\JSONResponse::class, $response);
}

public function testDisable(): void {
Expand All @@ -97,6 +97,6 @@ public function testDisable(): void {
->method('deleteAllBirthdayCalendars');

$response = $this->controller->disable();
$this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $response);
$this->assertInstanceOf(\OCP\AppFramework\Http\JSONResponse::class, $response);
}
}
4 changes: 2 additions & 2 deletions apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,8 @@ public function testCreateTagInByIdCollection($userVisible, $userAssignable, $gr

public function nodeClassProvider() {
return [
['\OCA\DAV\SystemTag\SystemTagsByIdCollection'],
['\OCA\DAV\SystemTag\SystemTagsObjectMappingCollection'],
[\OCA\DAV\SystemTag\SystemTagsByIdCollection::class],
[\OCA\DAV\SystemTag\SystemTagsObjectMappingCollection::class],
];
}

Expand Down
10 changes: 5 additions & 5 deletions apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function testGetChild(): void {

$childNode = $this->getNode()->getChild('123');

$this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagNode', $childNode);
$this->assertInstanceOf(\OCA\DAV\SystemTag\SystemTagNode::class, $childNode);
$this->assertEquals('123', $childNode->getName());
$this->assertEquals($tag, $childNode->getSystemTag());
}
Expand Down Expand Up @@ -145,8 +145,8 @@ public function testGetChildrenAdmin(): void {

$this->assertCount(2, $children);

$this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagNode', $children[0]);
$this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagNode', $children[1]);
$this->assertInstanceOf(\OCA\DAV\SystemTag\SystemTagNode::class, $children[0]);
$this->assertInstanceOf(\OCA\DAV\SystemTag\SystemTagNode::class, $children[1]);
$this->assertEquals($tag1, $children[0]->getSystemTag());
$this->assertEquals($tag2, $children[1]->getSystemTag());
}
Expand All @@ -164,8 +164,8 @@ public function testGetChildrenNonAdmin(): void {

$this->assertCount(2, $children);

$this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagNode', $children[0]);
$this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagNode', $children[1]);
$this->assertInstanceOf(\OCA\DAV\SystemTag\SystemTagNode::class, $children[0]);
$this->assertInstanceOf(\OCA\DAV\SystemTag\SystemTagNode::class, $children[1]);
$this->assertEquals($tag1, $children[0]->getSystemTag());
$this->assertEquals($tag2, $children[1]->getSystemTag());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function testGetChild(): void {

$childNode = $this->getNode()->getChild('555');

$this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagMappingNode', $childNode);
$this->assertInstanceOf(\OCA\DAV\SystemTag\SystemTagMappingNode::class, $childNode);
$this->assertEquals('555', $childNode->getName());
}

Expand Down Expand Up @@ -251,8 +251,8 @@ public function testGetChildren(): void {

$this->assertCount(2, $children);

$this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagMappingNode', $children[0]);
$this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagMappingNode', $children[1]);
$this->assertInstanceOf(\OCA\DAV\SystemTag\SystemTagMappingNode::class, $children[0]);
$this->assertInstanceOf(\OCA\DAV\SystemTag\SystemTagMappingNode::class, $children[1]);

$this->assertEquals(111, $children[0]->getObjectId());
$this->assertEquals('files', $children[0]->getObjectType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function testGetChild(): void {
->willReturn($this->createMock(\OCP\Files\Node::class));
$childNode = $this->node->getChild('555');

$this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagsObjectMappingCollection', $childNode);
$this->assertInstanceOf(\OCA\DAV\SystemTag\SystemTagsObjectMappingCollection::class, $childNode);
$this->assertEquals('555', $childNode->getName());
}

Expand Down
2 changes: 1 addition & 1 deletion apps/encryption/lib/Command/FixEncryptedVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private function correctEncryptedVersion(string $path, OutputInterface $output,
return true;
}

if ($storage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')) {
if ($storage->instanceOfStorage(\OCA\Files_Sharing\ISharedStorage::class)) {
$output->writeln("<info>The file: \"$path\" is a share. Please also run the script for the owner of the share</info>");
return true;
}
Expand Down
Loading

0 comments on commit 275a8ce

Please sign in to comment.