Skip to content

Commit 3df026e

Browse files
committed
chore: psalm fixes
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 4cb718e commit 3df026e

4 files changed

Lines changed: 26 additions & 5 deletions

File tree

apps/sharing/tests/Command/CommandTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use OCP\Sharing\Permission\SharePermission;
3434
use OCP\Sharing\Property\ShareProperty;
3535
use OCP\Sharing\Recipient\ShareRecipient;
36+
use OCP\Sharing\Share;
3637
use OCP\Sharing\ShareAccessContext;
3738
use OCP\Sharing\ShareState;
3839
use OCP\Sharing\Source\ShareSource;
@@ -42,6 +43,9 @@
4243
use Symfony\Component\Console\Output\Output;
4344
use Test\Sharing\AbstractSharingManagerTests;
4445

46+
/**
47+
* @psalm-import-type SharingShare from Share
48+
*/
4549
#[Group(name: 'DB')]
4650
final class CommandTest extends AbstractSharingManagerTests {
4751
/** @var list<class-string<SharingBase>> */
@@ -363,7 +367,7 @@ protected function deleteShare(ShareAccessContext $accessContext, string $id): v
363367
}
364368

365369
/**
366-
* @return array<string, mixed>
370+
* @return SharingShare
367371
*/
368372
#[Override]
369373
protected function getShare(ShareAccessContext $accessContext, string $id): array {
@@ -380,7 +384,7 @@ protected function getShare(ShareAccessContext $accessContext, string $id): arra
380384
}
381385

382386
/**
383-
* @return array<string, mixed>
387+
* @return SharingShare[]
384388
*/
385389
#[Override]
386390
protected function getShares(ShareAccessContext $accessContext, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array {

apps/sharing/tests/Controller/ApiV1ControllerTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,18 @@
2222
use OCP\Sharing\Permission\SharePermission;
2323
use OCP\Sharing\Property\ShareProperty;
2424
use OCP\Sharing\Recipient\ShareRecipient;
25+
use OCP\Sharing\Share;
2526
use OCP\Sharing\ShareAccessContext;
2627
use OCP\Sharing\ShareState;
2728
use OCP\Sharing\Source\ShareSource;
2829
use PHPUnit\Framework\Attributes\Group;
2930
use Test\Sharing\AbstractSharingManagerTests;
3031

3132
// TODO: Use Dispatcher
33+
34+
/**
35+
* @psalm-import-type SharingShare from Share
36+
*/
3237
#[Group(name: 'DB')]
3338
final class ApiV1ControllerTest extends AbstractSharingManagerTests {
3439
public function testDefaultShareAccessContext(): void {
@@ -146,11 +151,17 @@ protected function deleteShare(ShareAccessContext $accessContext, string $id): v
146151
$this->executeRequest($accessContext, fn (ApiV1Controller $controller): DataResponse => $controller->deleteShare($id));
147152
}
148153

154+
/**
155+
* @psalm-suppress MixedReturnTypeCoercion
156+
*/
149157
#[Override]
150158
protected function getShare(ShareAccessContext $accessContext, string $id): array {
151159
return $this->executeRequest(new ShareAccessContext($accessContext->currentUser, null, [], $accessContext->overrideChecks), fn (ApiV1Controller $controller): DataResponse => $controller->getShare($id, $accessContext->secret, $accessContext->arguments));
152160
}
153161

162+
/**
163+
* @psalm-suppress MixedReturnTypeCoercion
164+
*/
154165
#[Override]
155166
protected function getShares(ShareAccessContext $accessContext, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array {
156167
return $this->executeRequest($accessContext, function (ApiV1Controller $controller) use ($filterSourceTypeClass, $filterSourceTypeValue, $lastShareID, $limit): DataResponse {

tests/lib/Sharing/AbstractSharingManagerTests.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
/**
3636
* @psalm-import-type SharingShare from Share
3737
* @psalm-import-type SharingRecipient from Share
38+
*
39+
* @psalm-suppress RedundantConditionGivenDocblockType
40+
* @psalm-suppress PossiblyUndefinedArrayOffset
3841
*/
3942
abstract class AbstractSharingManagerTests extends TestCase {
4043
abstract protected function searchRecipients(ShareAccessContext $accessContext, ?array $filterRecipientTypeClasses, string $query, int $limit, int $offset, ?string $id = null): array;
@@ -61,8 +64,14 @@ abstract protected function selectSharePermissionPreset(ShareAccessContext $acce
6164

6265
abstract protected function deleteShare(ShareAccessContext $accessContext, string $id): void;
6366

67+
/**
68+
* @return SharingShare
69+
*/
6470
abstract protected function getShare(ShareAccessContext $accessContext, string $id): array;
6571

72+
/**
73+
* @return SharingShare[]
74+
*/
6675
abstract protected function getShares(ShareAccessContext $accessContext, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array;
6776

6877
protected IDBConnection $dbConnection;

tests/lib/Sharing/SharingManagerTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,6 @@ protected function getShare(ShareAccessContext $accessContext, string $id): arra
207207
}
208208
}
209209

210-
/**
211-
* @return mixed[][]
212-
*/
213210
#[\Override]
214211
protected function getShares(ShareAccessContext $accessContext, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array {
215212
try {

0 commit comments

Comments
 (0)