Skip to content
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: Change callback notation to be more readable #3244

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading