Skip to content

Commit

Permalink
refactor: Change callback notation to be more readable
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <kate@provokateurin.de>
  • Loading branch information
provokateurin committed Sep 17, 2024
1 parent b8a6d00 commit 490f74f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions lib/ACL/ACLCacheWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/CacheListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions lib/Controller/FolderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/DAV/ACLPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lib/DAV/GroupFoldersHome.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lib/DAV/PropFindPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 490f74f

Please sign in to comment.