From fd14234a6a6998fad403bc5c62ac44d0e26b4d38 Mon Sep 17 00:00:00 2001 From: nextcloud-command Date: Sun, 24 May 2026 14:56:18 +0000 Subject: [PATCH] refactor: Apply rector changes Signed-off-by: GitHub --- apps/dav/lib/Connector/Sabre/File.php | 3 ++- core/Controller/UpdateController.php | 3 ++- core/Service/CronService.php | 2 +- lib/private/App/AppManager.php | 3 ++- lib/private/Files/Cache/Cache.php | 10 ++++------ tests/lib/Files/Storage/Wrapper/QuotaTest.php | 5 +++-- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index 7f5e049c32912..f2bb588cbc450 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -29,6 +29,7 @@ use OCP\Files\InvalidContentException; use OCP\Files\InvalidPathException; use OCP\Files\LockNotAcquiredException; +use OCP\Files\NotEnoughSpaceException; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OCP\Files\Storage\IWriteStreamStorage; @@ -621,7 +622,7 @@ private function convertToSabreException(\Exception $e) { if ($e instanceof NotFoundException) { throw new NotFound($this->l10n->t('File not found: %1$s', [$e->getMessage()]), 0, $e); } - if ($e instanceof Files\NotEnoughSpaceException) { + if ($e instanceof NotEnoughSpaceException) { throw new EntityTooLarge($this->l10n->t('Insufficient space'), 0, $e); } diff --git a/core/Controller/UpdateController.php b/core/Controller/UpdateController.php index fee14e00dc7fc..14308c12d51f5 100644 --- a/core/Controller/UpdateController.php +++ b/core/Controller/UpdateController.php @@ -25,6 +25,7 @@ use OCP\AppFramework\Http\Attribute\OpenAPI; use OCP\AppFramework\Http\Attribute\PublicPage; use OCP\AppFramework\Http\DataResponse; +use OCP\AppFramework\OCSController; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\IEventSourceFactory; @@ -34,7 +35,7 @@ use Psr\Log\LoggerInterface; #[OpenAPI(scope: OpenApi::SCOPE_IGNORE)] -class UpdateController extends \OCP\AppFramework\OCSController { +class UpdateController extends OCSController { public function __construct( string $appName, IRequest $request, diff --git a/core/Service/CronService.php b/core/Service/CronService.php index 60f9cccfd86d9..8e4c080ebe1ee 100644 --- a/core/Service/CronService.php +++ b/core/Service/CronService.php @@ -157,7 +157,7 @@ private function runCli(string $appMode, ?array $jobClasses): void { } // Try to log and unlock job in case of failure (eg. Allowed memory size exhausted) - register_shutdown_function(function () { + register_shutdown_function(function (): void { $error = error_get_last(); if ($error === null) { return; diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 1f91825733713..93015d29d7fe7 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -36,6 +36,7 @@ use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserSession; +use OCP\L10N\IFactory; use OCP\Server; use OCP\ServerVersion; use OCP\Settings\IManager as ISettingsManager; @@ -1240,7 +1241,7 @@ public function checkAppDependencies(string $appId, bool $ignoreMax = false): vo $missing = $this->dependencyAnalyzer->analyze($info, $ignoreMax); if ($missing !== []) { - $l = \OCP\Server::get(\OCP\L10N\IFactory::class)->get('core'); + $l = Server::get(IFactory::class)->get('core'); $missingMsg = implode(PHP_EOL, $missing); throw new \Exception( $l->t('App "%1$s" cannot be installed because the following dependencies are not fulfilled: %2$s', diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 19347d50e7590..f2db763156b3c 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -24,8 +24,6 @@ use OCP\Files\Cache\CacheEntryInsertedEvent; use OCP\Files\Cache\CacheEntryRemovedEvent; use OCP\Files\Cache\CacheEntryUpdatedEvent; -use OCP\Files\Cache\CacheInsertEvent; -use OCP\Files\Cache\CacheUpdateEvent; use OCP\Files\Cache\ICache; use OCP\Files\Cache\ICacheEntry; use OCP\Files\Config\IUserMountCache; @@ -332,7 +330,7 @@ public function insert($file, array $data) { } $event = new CacheEntryInsertedEvent($this->storage, $file, $fileId, $storageId); - $this->eventDispatcher->dispatch(CacheInsertEvent::class, $event); + $this->eventDispatcher->dispatch(CacheEntryInsertedEvent::class, $event); $this->eventDispatcher->dispatchTyped($event); return $fileId; } @@ -436,7 +434,7 @@ public function update($id, array $data) { // path can still be null if the file doesn't exist if ($path !== null) { $event = new CacheEntryUpdatedEvent($this->storage, $path, $id, $this->getNumericStorageId()); - $this->eventDispatcher->dispatch(CacheUpdateEvent::class, $event); + $this->eventDispatcher->dispatch(CacheEntryUpdatedEvent::class, $event); $this->eventDispatcher->dispatchTyped($event); } } @@ -850,11 +848,11 @@ public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { $this->eventDispatcher->dispatchTyped(new CacheEntriesRemovedEvent([$event])); $event = new CacheEntryInsertedEvent($this->storage, $targetPath, $sourceId, $this->getNumericStorageId()); - $this->eventDispatcher->dispatch(CacheInsertEvent::class, $event); + $this->eventDispatcher->dispatch(CacheEntryInsertedEvent::class, $event); $this->eventDispatcher->dispatchTyped($event); } else { $event = new CacheEntryUpdatedEvent($this->storage, $targetPath, $sourceId, $this->getNumericStorageId()); - $this->eventDispatcher->dispatch(CacheUpdateEvent::class, $event); + $this->eventDispatcher->dispatch(CacheEntryUpdatedEvent::class, $event); $this->eventDispatcher->dispatchTyped($event); } } else { diff --git a/tests/lib/Files/Storage/Wrapper/QuotaTest.php b/tests/lib/Files/Storage/Wrapper/QuotaTest.php index ac658031ff3fe..150917b9dd9e9 100644 --- a/tests/lib/Files/Storage/Wrapper/QuotaTest.php +++ b/tests/lib/Files/Storage/Wrapper/QuotaTest.php @@ -13,6 +13,7 @@ use OC\Files\Storage\Local; use OC\Files\Storage\Wrapper\Quota; use OCP\Files; +use OCP\Files\NotEnoughSpaceException; use OCP\ITempManager; use OCP\Server; @@ -246,14 +247,14 @@ public function testNoWriteStreamQuota(): void { $stream = fopen('php://temp', 'w+'); fwrite($stream, 'foobar'); rewind($stream); - $this->expectException(Files\NotEnoughSpaceException::class); + $this->expectException(NotEnoughSpaceException::class); $instance->writeStream('files/test.txt', $stream); } public function testNoWriteStreamQuotaZero(): void { $instance = $this->getLimitedStorage(0.0); $stream = fopen('php://temp', 'w+'); - $this->expectException(Files\NotEnoughSpaceException::class); + $this->expectException(NotEnoughSpaceException::class); $instance->writeStream('files/test.txt', $stream); } }