From 57a435282f167b4946e5770c7c7d334eeaca84b4 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Thu, 18 Apr 2024 12:42:07 +0200 Subject: [PATCH] fix: psalm issues Signed-off-by: Marcel Klehr --- lib/Hooks/FileListener.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/Hooks/FileListener.php b/lib/Hooks/FileListener.php index d15d25f1..fa38c56b 100644 --- a/lib/Hooks/FileListener.php +++ b/lib/Hooks/FileListener.php @@ -61,6 +61,7 @@ public function __construct(FaceDetectionMapper $faceDetectionMapper, LoggerInte $this->storageService = $storageService; $this->shareManager = $shareManager; $this->rootFolder = $rootFolder; + $this->sourceUserIds = []; } public function handle(Event $event): void { @@ -70,6 +71,7 @@ public function handle(Event $event): void { $ownerId = $share->getShareOwner(); $node = $share->getNode(); + /** @var array{users:array, remote: array, mail: array} $accessList */ $accessList = $this->shareManager->getAccessList($node, true, true); $userIds = array_map(fn ($id) => strval($id), array_keys($accessList['users'])); @@ -106,10 +108,8 @@ public function handle(Event $event): void { $share = $event->getShare(); $node = $share->getNode(); + /** @var array{users:array, remote: array, mail: array} $accessList */ $accessList = $this->shareManager->getAccessList($node, true, true); - /** - * @var string[] $userIds - */ $userIds = array_keys($accessList['users']); if ($node->getType() === FileInfo::TYPE_FOLDER) { @@ -137,6 +137,7 @@ public function handle(Event $event): void { } else { $this->movingFromIgnoredTerritory = false; } + /** @var array{users:array, remote: array, mail: array} $sourceAccessList */ $sourceAccessList = $this->shareManager->getAccessList($event->getSource(), true, true); $this->sourceUserIds = array_map(fn ($id) => strval($id), array_keys($sourceAccessList['users'])); return; @@ -333,6 +334,7 @@ public function postInsert(Node $node, bool $recurse = true): void { } public function postRename(Node $source, Node $target): void { + /** @var array{users:array, remote: array, mail: array} $targetAccessList */ $targetAccessList = $this->shareManager->getAccessList($target, true, true); $targetUserIds = array_map(fn ($id) => strval($id), array_keys($targetAccessList['users'])); @@ -343,10 +345,11 @@ public function postRename(Node $source, Node $target): void { if ($target->getType() === FileInfo::TYPE_FOLDER) { $mount = $target->getMountPoint(); - if ($mount->getNumericStorageId() === null) { + $numericStorageId = $mount->getNumericStorageId(); + if ($numericStorageId === null) { return; } - $files = $this->storageService->getFilesInMount($mount->getNumericStorageId(), $target->getId(), [ClusteringFaceClassifier::MODEL_NAME], 0, 0); + $files = $this->storageService->getFilesInMount($numericStorageId, $target->getId(), [ClusteringFaceClassifier::MODEL_NAME], 0, 0); foreach ($files as $fileInfo) { foreach ($usersToAdd as $userId) { if (count($this->faceDetectionMapper->findByFileIdAndUser($target->getId(), $userId)) > 0) {