-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(apps): Use PHP 5.5 features #48362
Conversation
Signed-off-by: provokateurin <kate@provokateurin.de>
@@ -232,6 +232,6 @@ | |||
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'); |
Check notice
Code scanning / Psalm
DeprecatedMethod Note
@@ -147,6 +147,6 @@ | |||
} | |||
|
|||
private function registerHooks(): void { | |||
Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig'); | |||
Util::connectHook('\OCP\Config', 'js', \OCA\Files\App::class, 'extendJsConfig'); |
Check notice
Code scanning / Psalm
DeprecatedMethod Note
@@ -70,13 +70,13 @@ | |||
/** @var Scanner $scanner */ | |||
$scanner = $storage->getScanner(); | |||
|
|||
$scanner->listen('\OC\Files\Cache\Scanner', 'scanFile', function (string $path) use ($output): void { | |||
$scanner->listen(\OC\Files\Cache\Scanner::class, 'scanFile', function (string $path) use ($output): void { |
Check notice
Code scanning / Psalm
DeprecatedMethod Note
$output->writeln("\tFile\t<info>$path</info>", OutputInterface::VERBOSITY_VERBOSE); | ||
++$this->filesCounter; | ||
$this->abortIfInterrupted(); | ||
}); | ||
|
||
$scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function (string $path) use ($output): void { | ||
$scanner->listen(\OC\Files\Cache\Scanner::class, 'scanFolder', function (string $path) use ($output): void { |
Check notice
Code scanning / Psalm
DeprecatedMethod Note
@@ -226,7 +226,7 @@ | |||
throw new QueryException(); | |||
} | |||
|
|||
return $this->serverContainer->get('\OCA\Talk\Share\Helper\DeletedShareAPIController'); | |||
return $this->serverContainer->get(\OCA\Talk\Share\Helper\DeletedShareAPIController::class); |
Check failure
Code scanning / Psalm
UndefinedClass Error
@@ -12,10 +12,10 @@ | |||
|
|||
class Helper { | |||
public static function registerHooks() { | |||
\OCP\Util::connectHook('OC_Filesystem', 'post_rename', '\OCA\Files_Sharing\Updater', 'renameHook'); | |||
\OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren'); | |||
\OCP\Util::connectHook('OC_Filesystem', 'post_rename', \OCA\Files_Sharing\Updater::class, 'renameHook'); |
Check notice
Code scanning / Psalm
DeprecatedMethod Note
\OCP\Util::connectHook('OC_Filesystem', 'post_rename', '\OCA\Files_Sharing\Updater', 'renameHook'); | ||
\OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren'); | ||
\OCP\Util::connectHook('OC_Filesystem', 'post_rename', \OCA\Files_Sharing\Updater::class, 'renameHook'); | ||
\OCP\Util::connectHook('OC_Filesystem', 'post_delete', \OCA\Files_Sharing\Hooks::class, 'unshareChildren'); |
Check notice
Code scanning / Psalm
DeprecatedMethod Note
|
||
\OCP\Util::connectHook('OC_User', 'post_deleteUser', '\OCA\Files_Sharing\Hooks', 'deleteUser'); | ||
\OCP\Util::connectHook('OC_User', 'post_deleteUser', \OCA\Files_Sharing\Hooks::class, 'deleteUser'); |
Check notice
Code scanning / Psalm
DeprecatedMethod Note
@@ -256,7 +256,7 @@ | |||
* That's why PSALM doesn't know the class GroupTrashItem. | |||
* @psalm-suppress RedundantCondition | |||
*/ | |||
if ($scope === self::SCOPE_GROUPFOLDERS && $trashItemClass !== 'OCA\GroupFolders\Trash\GroupTrashItem') { | |||
if ($scope === self::SCOPE_GROUPFOLDERS && $trashItemClass !== \OCA\GroupFolders\Trash\GroupTrashItem::class) { |
Check failure
Code scanning / Psalm
UndefinedClass Error
@@ -505,7 +505,7 @@ | |||
$view->chroot('/' . $user . '/files'); | |||
$view->touch('/' . $location . '/' . $uniqueFilename, $mtime); | |||
$view->chroot($fakeRoot); | |||
\OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => $targetPath, 'trashPath' => $sourcePath]); | |||
\OCP\Util::emitHook(\OCA\Files_Trashbin\Trashbin::class, 'post_restore', ['filePath' => $targetPath, 'trashPath' => $sourcePath]); |
Check notice
Code scanning / Psalm
DeprecatedMethod Note
@@ -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'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was created by Christoph the other day.
It is a breaking change:
var_dump('\OCA\Files_Trashbin\Trashbin' === \OCA\Files_Trashbin\Trashbin::class);
// bool(false)
We can only do this, if we modify the hooker itself and basically trim leading slashes on connect and emit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the comparison fails, but shouldn't the ::class result in the exact same string content?
Maybe I'm missing something here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\OCA\Files_Trashbin\Trashbin::class
is 'OCA\Files_Trashbin\Trashbin'
without the first \
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, in the preview IntelliJ displayed it to me with the leading backslash 🤷♀️
Another problem as Psalm reported it: Class strings for classes from apps outside of server don't work. Using stubs for that should be fine, right? And there shouldn't be any problem with loading that code even if the class is not available? |
Yeah psalm is annoying with that. It’s perfectly valid to use |
Summary
Setting rector PHP level to 5.3 and 5.4 did not lead to any changes so we can start at 5.5 right away.
Checklist