From f56f0e8b4b3a240954fe2d6e01ef586181c47ec9 Mon Sep 17 00:00:00 2001 From: Pascal Prugna Date: Tue, 8 Jul 2025 12:01:42 +0200 Subject: [PATCH 1/3] fix: accept INavigationManager instead of NavigationManager in FilteredNavigationManager + cs fix - The constructor of FilteredNavigationManager now type-hints INavigationManager as the second argument, instead of the concrete NavigationManager class. - This increases compatibility with proxy and decorated navigation managers, improving app interoperability. Signed-off-by: Pascal Prugna --- lib/FilteredNavigationManager.php | 18 ++++++------------ lib/Storage/DirMask.php | 4 ++-- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/lib/FilteredNavigationManager.php b/lib/FilteredNavigationManager.php index b56edfb2..25d5b494 100644 --- a/lib/FilteredNavigationManager.php +++ b/lib/FilteredNavigationManager.php @@ -8,22 +8,16 @@ namespace OCA\Guests; use OC\NavigationManager; +use OCP\INavigationManager; use OCP\IUser; class FilteredNavigationManager extends NavigationManager { - /** @var AppWhitelist */ - private $whitelist; - /** @var IUser */ - private $user; - - /** @var NavigationManager */ - private $navigationManager; - - public function __construct(IUser $user, NavigationManager $navigationManager, AppWhitelist $whitelist) { - $this->whitelist = $whitelist; - $this->user = $user; - $this->navigationManager = $navigationManager; + public function __construct( + private IUser $user, + private INavigationManager $navigationManager, + private AppWhitelist $whitelist, + ) { } public function getAll(string $type = 'link'): array { diff --git a/lib/Storage/DirMask.php b/lib/Storage/DirMask.php index ef59f8a6..cdceb280 100644 --- a/lib/Storage/DirMask.php +++ b/lib/Storage/DirMask.php @@ -44,7 +44,7 @@ public function __construct($arguments) { $this->mask = $arguments['mask']; } - protected function checkPath($path): bool { + protected function checkPath(string $path): bool { return $path === $this->path || substr($path, 0, $this->pathLength + 1) === $this->path . '/'; } @@ -56,7 +56,7 @@ public function isUpdatable($path): bool { } } - public function isCreatable($path): bool { + public function isCreatable(string $path): bool { if ($this->checkPath($path)) { return parent::isCreatable($path); } else { From 64eac5b3476a8c41786f7b94ed2d22bdfef57355 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Wed, 16 Jul 2025 18:02:28 +0200 Subject: [PATCH 2/3] fix: psalm issues Signed-off-by: Julien Veyssier --- composer.json | 1 + lib/Storage/DirMask.php | 2 +- tests/psalm-baseline.xml | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6b59429c..ead4d519 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ "cs:fix": "php-cs-fixer fix", "psalm": "psalm --threads=1", "psalm:update-baseline": "psalm --threads=1 --update-baseline", + "psalm:update-baseline:force": "psalm --threads=1 --update-baseline --set-baseline=tests/psalm-baseline.xml", "psalm:clear": "psalm --clear-cache && psalm --clear-global-cache", "psalm:fix": "psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MismatchingDocblockParamType,MismatchingDocblockReturnType,MissingParamType,InvalidFalsableReturnType", "test:unit": "vendor/bin/phpunit -c phpunit.xml" diff --git a/lib/Storage/DirMask.php b/lib/Storage/DirMask.php index cdceb280..4e43c060 100644 --- a/lib/Storage/DirMask.php +++ b/lib/Storage/DirMask.php @@ -56,7 +56,7 @@ public function isUpdatable($path): bool { } } - public function isCreatable(string $path): bool { + public function isCreatable($path): bool { if ($this->checkPath($path)) { return parent::isCreatable($path); } else { diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml index 11939669..25d0844f 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -4,11 +4,24 @@ - SPDX-License-Identifier: AGPL-3.0-or-later --> + + + + + + + + + + + + + From 68e4b12bbee8ebb0b4e12cf87d0bccdb7cbb1e33 Mon Sep 17 00:00:00 2001 From: Pascal Prugna Date: Mon, 21 Jul 2025 09:34:58 +0200 Subject: [PATCH 3/3] fix: psalm errors on FilteredNavigationManager Signed-off-by: Pascal Prugna --- lib/FilteredNavigationManager.php | 9 +++++++++ tests/psalm-baseline.xml | 18 ------------------ tests/stub.php | 5 +++++ 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/lib/FilteredNavigationManager.php b/lib/FilteredNavigationManager.php index 25d5b494..650b6a38 100644 --- a/lib/FilteredNavigationManager.php +++ b/lib/FilteredNavigationManager.php @@ -50,14 +50,23 @@ public function setUnreadCounter(string $id, int $unreadCounter): void { $this->navigationManager->setUnreadCounter($id, $unreadCounter); } + /** + * @psalm-suppress MethodSignatureMismatch + */ public function get(string $id): ?array { return $this->navigationManager->get($id); } + /** + * @psalm-suppress MethodSignatureMismatch + */ public function getDefaultEntryIdForUser(?IUser $user = null, bool $withFallbacks = true): string { return $this->navigationManager->getDefaultEntryIdForUser($user, $withFallbacks); } + /** + * @psalm-suppress MethodSignatureMismatch + */ public function getDefaultEntryIds(bool $withFallbacks = true): array { return $this->navigationManager->getDefaultEntryIds($withFallbacks); } diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml index 25d0844f..0c21b50a 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -4,27 +4,9 @@ - SPDX-License-Identifier: AGPL-3.0-or-later --> - - - - - - - - - - - - - - - - - - diff --git a/tests/stub.php b/tests/stub.php index 35b166d1..0a711f6b 100644 --- a/tests/stub.php +++ b/tests/stub.php @@ -827,3 +827,8 @@ class LoadAdditionalScriptsEvent extends \OCP\EventDispatcher\Event { class BeforeTemplateRenderedEvent extends Event { } } + +namespace OCA\Files_External\Config { + class ExternalMountPoint { + } +}