From 3df026ed09937eb8399ccb253e2af8bfc9612cac Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 27 Jul 2026 23:22:34 +0200 Subject: [PATCH] chore: psalm fixes Signed-off-by: Robin Appelman --- apps/sharing/tests/Command/CommandTest.php | 8 ++++++-- apps/sharing/tests/Controller/ApiV1ControllerTest.php | 11 +++++++++++ tests/lib/Sharing/AbstractSharingManagerTests.php | 9 +++++++++ tests/lib/Sharing/SharingManagerTest.php | 3 --- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/apps/sharing/tests/Command/CommandTest.php b/apps/sharing/tests/Command/CommandTest.php index b10dfef40c3..934dfdcf7a6 100644 --- a/apps/sharing/tests/Command/CommandTest.php +++ b/apps/sharing/tests/Command/CommandTest.php @@ -33,6 +33,7 @@ use OCP\Sharing\ISharingRegistry; use OCP\Sharing\Permission\SharePermission; use OCP\Sharing\Property\ShareProperty; use OCP\Sharing\Recipient\ShareRecipient; +use OCP\Sharing\Share; use OCP\Sharing\ShareAccessContext; use OCP\Sharing\ShareState; use OCP\Sharing\Source\ShareSource; @@ -42,6 +43,9 @@ use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\Output; use Test\Sharing\AbstractSharingManagerTests; +/** + * @psalm-import-type SharingShare from Share + */ #[Group(name: 'DB')] final class CommandTest extends AbstractSharingManagerTests { /** @var list> */ @@ -363,7 +367,7 @@ final class CommandTest extends AbstractSharingManagerTests { } /** - * @return array + * @return SharingShare */ #[Override] protected function getShare(ShareAccessContext $accessContext, string $id): array { @@ -380,7 +384,7 @@ final class CommandTest extends AbstractSharingManagerTests { } /** - * @return array + * @return SharingShare[] */ #[Override] protected function getShares(ShareAccessContext $accessContext, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array { diff --git a/apps/sharing/tests/Controller/ApiV1ControllerTest.php b/apps/sharing/tests/Controller/ApiV1ControllerTest.php index bfee7b02015..2424aba18d1 100644 --- a/apps/sharing/tests/Controller/ApiV1ControllerTest.php +++ b/apps/sharing/tests/Controller/ApiV1ControllerTest.php @@ -22,6 +22,7 @@ use OCP\Sharing\ISharingRegistry; use OCP\Sharing\Permission\SharePermission; use OCP\Sharing\Property\ShareProperty; use OCP\Sharing\Recipient\ShareRecipient; +use OCP\Sharing\Share; use OCP\Sharing\ShareAccessContext; use OCP\Sharing\ShareState; use OCP\Sharing\Source\ShareSource; @@ -29,6 +30,10 @@ use PHPUnit\Framework\Attributes\Group; use Test\Sharing\AbstractSharingManagerTests; // TODO: Use Dispatcher + +/** + * @psalm-import-type SharingShare from Share + */ #[Group(name: 'DB')] final class ApiV1ControllerTest extends AbstractSharingManagerTests { public function testDefaultShareAccessContext(): void { @@ -146,11 +151,17 @@ final class ApiV1ControllerTest extends AbstractSharingManagerTests { $this->executeRequest($accessContext, fn (ApiV1Controller $controller): DataResponse => $controller->deleteShare($id)); } + /** + * @psalm-suppress MixedReturnTypeCoercion + */ #[Override] protected function getShare(ShareAccessContext $accessContext, string $id): array { return $this->executeRequest(new ShareAccessContext($accessContext->currentUser, null, [], $accessContext->overrideChecks), fn (ApiV1Controller $controller): DataResponse => $controller->getShare($id, $accessContext->secret, $accessContext->arguments)); } + /** + * @psalm-suppress MixedReturnTypeCoercion + */ #[Override] protected function getShares(ShareAccessContext $accessContext, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array { return $this->executeRequest($accessContext, function (ApiV1Controller $controller) use ($filterSourceTypeClass, $filterSourceTypeValue, $lastShareID, $limit): DataResponse { diff --git a/tests/lib/Sharing/AbstractSharingManagerTests.php b/tests/lib/Sharing/AbstractSharingManagerTests.php index 2005bcbb537..b3420efc829 100644 --- a/tests/lib/Sharing/AbstractSharingManagerTests.php +++ b/tests/lib/Sharing/AbstractSharingManagerTests.php @@ -35,6 +35,9 @@ use Test\TestCase; /** * @psalm-import-type SharingShare from Share * @psalm-import-type SharingRecipient from Share + * + * @psalm-suppress RedundantConditionGivenDocblockType + * @psalm-suppress PossiblyUndefinedArrayOffset */ abstract class AbstractSharingManagerTests extends TestCase { abstract protected function searchRecipients(ShareAccessContext $accessContext, ?array $filterRecipientTypeClasses, string $query, int $limit, int $offset, ?string $id = null): array; @@ -61,8 +64,14 @@ abstract class AbstractSharingManagerTests extends TestCase { abstract protected function deleteShare(ShareAccessContext $accessContext, string $id): void; + /** + * @return SharingShare + */ abstract protected function getShare(ShareAccessContext $accessContext, string $id): array; + /** + * @return SharingShare[] + */ abstract protected function getShares(ShareAccessContext $accessContext, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array; protected IDBConnection $dbConnection; diff --git a/tests/lib/Sharing/SharingManagerTest.php b/tests/lib/Sharing/SharingManagerTest.php index 117cb18c54d..519b60e1b6c 100644 --- a/tests/lib/Sharing/SharingManagerTest.php +++ b/tests/lib/Sharing/SharingManagerTest.php @@ -207,9 +207,6 @@ final class SharingManagerTest extends AbstractSharingManagerTests { } } - /** - * @return mixed[][] - */ #[\Override] protected function getShares(ShareAccessContext $accessContext, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array { try {