From 490f74fb2a643edced333c0d5d68f2fd74f77ef9 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Tue, 17 Sep 2024 17:29:33 +0200 Subject: [PATCH] refactor: Change callback notation to be more readable Signed-off-by: provokateurin --- lib/ACL/ACLCacheWrapper.php | 6 +++--- lib/CacheListener.php | 4 ++-- lib/Controller/FolderController.php | 6 +++--- lib/DAV/ACLPlugin.php | 4 ++-- lib/DAV/GroupFoldersHome.php | 2 +- lib/DAV/PropFindPlugin.php | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/ACL/ACLCacheWrapper.php b/lib/ACL/ACLCacheWrapper.php index 62c3da8bb..7c0fb3182 100644 --- a/lib/ACL/ACLCacheWrapper.php +++ b/lib/ACL/ACLCacheWrapper.php @@ -63,19 +63,19 @@ public function getFolderContentsById($fileId) { public function search($pattern) { $results = $this->getCache()->search($pattern); $this->preloadEntries($results); - return array_filter(array_map([$this, 'formatCacheEntry'], $results)); + return array_filter(array_map($this->formatCacheEntry(...), $results)); } public function searchByMime($mimetype) { $results = $this->getCache()->searchByMime($mimetype); $this->preloadEntries($results); - return array_filter(array_map([$this, 'formatCacheEntry'], $results)); + return array_filter(array_map($this->formatCacheEntry(...), $results)); } public function searchQuery(ISearchQuery $query) { $results = $this->getCache()->searchQuery($query); $this->preloadEntries($results); - return array_filter(array_map([$this, 'formatCacheEntry'], $results)); + return array_filter(array_map($this->formatCacheEntry(...), $results)); } /** diff --git a/lib/CacheListener.php b/lib/CacheListener.php index 9e628cd47..4c88a2d5f 100644 --- a/lib/CacheListener.php +++ b/lib/CacheListener.php @@ -18,8 +18,8 @@ public function __construct(private IEventDispatcher $eventDispatcher) { } public function listen(): void { - $this->eventDispatcher->addListener(CacheInsertEvent::class, [$this, 'onCacheEvent'], 99999); - $this->eventDispatcher->addListener(CacheUpdateEvent::class, [$this, 'onCacheEvent'], 99999); + $this->eventDispatcher->addListener(CacheInsertEvent::class, $this->onCacheEvent(...), 99999); + $this->eventDispatcher->addListener(CacheUpdateEvent::class, $this->onCacheEvent(...), 99999); } public function onCacheEvent(ICacheEvent $event): void { diff --git a/lib/Controller/FolderController.php b/lib/Controller/FolderController.php index 669ceadc2..fc9057a3b 100644 --- a/lib/Controller/FolderController.php +++ b/lib/Controller/FolderController.php @@ -93,7 +93,7 @@ private function formatFolder(array $folder): array { #[ApiRoute(verb: 'GET', url: '/folders')] public function getFolders(bool $applicable = false): DataResponse { $folders = $this->manager->getAllFoldersWithSize($this->getRootFolderStorageId()); - $folders = array_map([$this, 'formatFolder'], $folders); + $folders = array_map($this->formatFolder(...), $folders); $isAdmin = $this->delegationService->isAdminNextcloud() || $this->delegationService->isDelegatedAdmin(); if ($isAdmin && !$applicable) { return new DataResponse($folders); @@ -102,7 +102,7 @@ public function getFolders(bool $applicable = false): DataResponse { $folders = $this->foldersFilter->getForApiUser($folders); } if ($applicable || !$this->delegationService->hasApiAccess()) { - $folders = array_map([$this, 'filterNonAdminFolder'], $folders); + $folders = array_map($this->filterNonAdminFolder(...), $folders); $folders = array_filter($folders); } return new DataResponse($folders); @@ -299,7 +299,7 @@ private function buildOCSResponseXML(string $format, DataResponse $data): V1Resp $folderData = $this->folderDataForXML($folderData); } elseif (is_array($folderData) && count($folderData) && isset(current($folderData)['id'])) { // folder list - $folderData = array_map([$this, 'folderDataForXML'], $folderData); + $folderData = array_map($this->folderDataForXML(...), $folderData); } $data->setData($folderData); return new V1Response($data, $format); diff --git a/lib/DAV/ACLPlugin.php b/lib/DAV/ACLPlugin.php index 0ff64151f..aec03aedd 100644 --- a/lib/DAV/ACLPlugin.php +++ b/lib/DAV/ACLPlugin.php @@ -56,8 +56,8 @@ public function initialize(Server $server): void { $this->server = $server; $this->user = $user = $this->userSession->getUser(); - $this->server->on('propFind', [$this, 'propFind']); - $this->server->on('propPatch', [$this, 'propPatch']); + $this->server->on('propFind', $this->propFind(...)); + $this->server->on('propPatch', $this->propPatch(...)); $this->server->xml->elementMap[Rule::ACL] = Rule::class; $this->server->xml->elementMap[self::ACL_LIST] = function (Reader $reader): array { diff --git a/lib/DAV/GroupFoldersHome.php b/lib/DAV/GroupFoldersHome.php index 2e3c39559..7634187a1 100644 --- a/lib/DAV/GroupFoldersHome.php +++ b/lib/DAV/GroupFoldersHome.php @@ -94,7 +94,7 @@ public function getChild($name) { */ public function getChildren(): array { $folders = $this->folderManager->getFoldersForUser($this->user, $this->rootFolder->getMountPoint()->getNumericStorageId()); - return array_map([$this, 'getDirectoryForFolder'], $folders); + return array_map($this->getDirectoryForFolder(...), $folders); } public function childExists($name): bool { diff --git a/lib/DAV/PropFindPlugin.php b/lib/DAV/PropFindPlugin.php index 971988a96..b605de4b3 100644 --- a/lib/DAV/PropFindPlugin.php +++ b/lib/DAV/PropFindPlugin.php @@ -37,7 +37,7 @@ public function getPluginName(): string { } public function initialize(Server $server): void { - $server->on('propFind', [$this, 'propFind']); + $server->on('propFind', $this->propFind(...)); } public function propFind(PropFind $propFind, INode $node): void {