diff options
author | provokateurin <kate@provokateurin.de> | 2024-09-24 15:53:13 +0200 |
---|---|---|
committer | provokateurin <kate@provokateurin.de> | 2024-11-05 09:58:11 +0100 |
commit | 77114fb3277742fc69ddcf2432311ecb263af97e (patch) | |
tree | 0f360660038c65acc5f9cd014f183e45b0c5355b /apps/files/lib/Helper.php | |
parent | 1140e41db2ef6241f806eb605df48642a2a32c62 (diff) | |
download | nextcloud-server-77114fb3277742fc69ddcf2432311ecb263af97e.tar.gz nextcloud-server-77114fb3277742fc69ddcf2432311ecb263af97e.zip |
fix(OpenAPI): Adjust array syntax to avoid ambiguitiesfix/openapi/array-syntax
Signed-off-by: provokateurin <kate@provokateurin.de>
Diffstat (limited to 'apps/files/lib/Helper.php')
-rw-r--r-- | apps/files/lib/Helper.php | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/apps/files/lib/Helper.php b/apps/files/lib/Helper.php index ce33bbb80a6..b66dc9a2056 100644 --- a/apps/files/lib/Helper.php +++ b/apps/files/lib/Helper.php @@ -192,37 +192,34 @@ class Helper { /** * Populate the result set with file tags * - * @param array $fileList - * @param string $fileIdentifier identifier attribute name for values in $fileList - * @param ITagManager $tagManager - * @return array file list populated with tags + * @psalm-template T of array{tags?: list<string>, file_source: int, ...array<string, mixed>} + * @param list<T> $fileList + * @return list<T> file list populated with tags */ - public static function populateTags(array $fileList, $fileIdentifier, ITagManager $tagManager) { - $ids = []; - foreach ($fileList as $fileData) { - $ids[] = $fileData[$fileIdentifier]; - } + public static function populateTags(array $fileList, ITagManager $tagManager) { $tagger = $tagManager->load('files'); - $tags = $tagger->getTagsForObjects($ids); + $tags = $tagger->getTagsForObjects(array_map(static fn (array $fileData) => $fileData['file_source'], $fileList)); if (!is_array($tags)) { throw new \UnexpectedValueException('$tags must be an array'); } // Set empty tag array - foreach ($fileList as $key => $fileData) { - $fileList[$key]['tags'] = []; + foreach ($fileList as &$fileData) { + $fileData['tags'] = []; } + unset($fileData); if (!empty($tags)) { foreach ($tags as $fileId => $fileTags) { - foreach ($fileList as $key => $fileData) { - if ($fileId !== $fileData[$fileIdentifier]) { + foreach ($fileList as &$fileData) { + if ($fileId !== $fileData['file_source']) { continue; } - $fileList[$key]['tags'] = $fileTags; + $fileData['tags'] = $fileTags; } + unset($fileData); } } |