diff --git a/lib/Service/SubmissionService.php b/lib/Service/SubmissionService.php index 2f48f0621..e8c036499 100644 --- a/lib/Service/SubmissionService.php +++ b/lib/Service/SubmissionService.php @@ -472,7 +472,7 @@ private function exportData(array $header, array $data, string $fileFormat, ?Fil $newSubmissionIds = []; if ($submissionIdColIndex !== false) { - $newSubmissionIds = array_map('strval', array_column($data, $submissionIdColIndex)); + $newSubmissionIds = array_map(strval(...), array_column($data, $submissionIdColIndex)); } // Sync Rows diff --git a/lib/ShareReview/ShareReviewSource.php b/lib/ShareReview/ShareReviewSource.php index 242667d8e..40b1b8b4f 100644 --- a/lib/ShareReview/ShareReviewSource.php +++ b/lib/ShareReview/ShareReviewSource.php @@ -61,7 +61,7 @@ public function getShares(): array { return []; } return array_map( - fn (array $share) => $this->buildEntry($share), + $this->buildEntry(...), $rawShares, ); } diff --git a/tests/Integration/Api/ApiV3Test.php b/tests/Integration/Api/ApiV3Test.php index aa8782b36..92c6e2592 100644 --- a/tests/Integration/Api/ApiV3Test.php +++ b/tests/Integration/Api/ApiV3Test.php @@ -1482,7 +1482,7 @@ public function testExportSubmissionsWithSync() { // 2. Verify Initial Export $content = $this->userFolder->get($exportPath)->getContent(); - $data = array_map('str_getcsv', explode("\n", trim($content))); + $data = array_map(str_getcsv(...), explode("\n", trim($content))); $this->assertCount(5, $data, 'Expected 5 rows: header, hidden-header, 3 data rows'); // Check headers @@ -1517,7 +1517,7 @@ public function testExportSubmissionsWithSync() { // 5. Verify Export after deletions $content = $this->userFolder->get($exportPath)->getContent(); - $data = array_map('str_getcsv', explode("\n", trim($content))); + $data = array_map(str_getcsv(...), explode("\n", trim($content))); $this->assertCount(4, $data, 'Expected 4 rows after deletion: header, hidden-header, 2 data rows'); $this->assertStringNotContainsString($question1['text'], implode(',', $data[0])); @@ -1538,7 +1538,7 @@ public function testExportSubmissionsWithSync() { // 8. Verify export after update $content = $this->userFolder->get($exportPath)->getContent(); - $data = array_map('str_getcsv', explode("\n", trim($content))); + $data = array_map(str_getcsv(...), explode("\n", trim($content))); $updatedRow = null; foreach (array_slice($data, 2) as $row) { diff --git a/tests/Unit/Db/ShareMapperTest.php b/tests/Unit/Db/ShareMapperTest.php index 8259f4595..979da03e5 100644 --- a/tests/Unit/Db/ShareMapperTest.php +++ b/tests/Unit/Db/ShareMapperTest.php @@ -23,8 +23,6 @@ class ShareMapperTest extends TestCase { private ShareMapper $shareMapper; protected function setUp(): void { - parent::setUp(); - $this->qb = $this->createMock(IQueryBuilder::class); $this->qb->method('select')->willReturnSelf(); $this->qb->method('selectAlias')->willReturnSelf(); diff --git a/tests/Unit/ShareReview/ShareReviewListenerTest.php b/tests/Unit/ShareReview/ShareReviewListenerTest.php index 2bff13542..d2222e547 100644 --- a/tests/Unit/ShareReview/ShareReviewListenerTest.php +++ b/tests/Unit/ShareReview/ShareReviewListenerTest.php @@ -19,7 +19,6 @@ final class ShareReviewListenerTest extends TestCase { private ShareReviewListener $listener; protected function setUp(): void { - parent::setUp(); $this->listener = new ShareReviewListener(); } diff --git a/tests/Unit/ShareReview/ShareReviewSourceTest.php b/tests/Unit/ShareReview/ShareReviewSourceTest.php index 85bb0c6c2..f262b1d2d 100644 --- a/tests/Unit/ShareReview/ShareReviewSourceTest.php +++ b/tests/Unit/ShareReview/ShareReviewSourceTest.php @@ -28,16 +28,15 @@ use Psr\Log\LoggerInterface; final class ShareReviewSourceTest extends TestCase { - private MockObject $shareMapper; - private MockObject $formMapper; - private MockObject $uploadedFilesShareService; - private MockObject $eventDispatcher; - private MockObject $logger; - private MockObject $l10n; + private ShareMapper|MockObject $shareMapper; + private FormMapper|MockObject $formMapper; + private UploadedFilesShareService|MockObject $uploadedFilesShareService; + private IEventDispatcher|MockObject $eventDispatcher; + private LoggerInterface|MockObject $logger; + private IL10N|MockObject $l10n; private ShareReviewSource $source; protected function setUp(): void { - parent::setUp(); $this->shareMapper = $this->createMock(ShareMapper::class); $this->formMapper = $this->createMock(FormMapper::class); $this->uploadedFilesShareService = $this->createMock(UploadedFilesShareService::class); @@ -45,9 +44,7 @@ protected function setUp(): void { $this->logger = $this->createMock(LoggerInterface::class); $this->l10n = $this->createMock(IL10N::class); $this->l10n->method('t')->willReturnCallback( - function (string $text, array $params = []): string { - return empty($params) ? $text : vsprintf($text, $params); - } + fn (string $text, array $params = []): string => empty($params) ? $text : vsprintf($text, $params) ); $this->source = new ShareReviewSource( $this->shareMapper, diff --git a/tests/Unit/ShareReview/Stubs.php b/tests/Unit/ShareReview/Stubs.php index 6c1bf9b4d..1c55fc87d 100644 --- a/tests/Unit/ShareReview/Stubs.php +++ b/tests/Unit/ShareReview/Stubs.php @@ -34,29 +34,29 @@ public function getSources(): array { } } - final class ShareReviewPermission { + final readonly class ShareReviewPermission { public function __construct( - public readonly string $id, - public readonly string $displayName, - public readonly ?string $hint = null, - public readonly int $priority = 50, + public string $id, + public string $displayName, + public ?string $hint = null, + public int $priority = 50, ) { } } - final class ShareReviewEntry { + final readonly class ShareReviewEntry { public function __construct( - public readonly string $id, - public readonly string $object, - public readonly string $initiator, - public readonly int $type, - public readonly string $recipient, - public readonly int $lastModifiedTimestamp, - public readonly array $permissions = [], - public readonly string $action = '', - public readonly bool $hasPassword = false, - public readonly ?int $expirationTimestamp = null, - public readonly ?string $parent = null, + public string $id, + public string $object, + public string $initiator, + public int $type, + public string $recipient, + public int $lastModifiedTimestamp, + public array $permissions = [], + public string $action = '', + public bool $hasPassword = false, + public ?int $expirationTimestamp = null, + public ?string $parent = null, ) { } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 5bec5b5c8..2a40e2a3d 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -20,6 +20,6 @@ Server::get(IAppManager::class)->loadApp('forms'); -if (!interface_exists('OCP\Share\ShareReview\IShareReviewSource')) { +if (!interface_exists(\OCP\Share\ShareReview\IShareReviewSource::class)) { require_once __DIR__ . '/Unit/ShareReview/Stubs.php'; } diff --git a/tests/stubs/ocp-share-sharereview.php b/tests/stubs/ocp-share-sharereview.php index cf8072853..c126d345c 100644 --- a/tests/stubs/ocp-share-sharereview.php +++ b/tests/stubs/ocp-share-sharereview.php @@ -25,29 +25,29 @@ public function getSources(): array { } } - final class ShareReviewPermission { + final readonly class ShareReviewPermission { public function __construct( - public readonly string $id, - public readonly string $displayName, - public readonly ?string $hint = null, - public readonly int $priority = 50, + public string $id, + public string $displayName, + public ?string $hint = null, + public int $priority = 50, ) { } } - final class ShareReviewEntry { + final readonly class ShareReviewEntry { public function __construct( - public readonly string $id, - public readonly string $object, - public readonly string $initiator, - public readonly int $type, - public readonly string $recipient, - public readonly int $lastModifiedTimestamp, - public readonly array $permissions = [], - public readonly string $action = '', - public readonly bool $hasPassword = false, - public readonly ?int $expirationTimestamp = null, - public readonly ?string $parent = null, + public string $id, + public string $object, + public string $initiator, + public int $type, + public string $recipient, + public int $lastModifiedTimestamp, + public array $permissions = [], + public string $action = '', + public bool $hasPassword = false, + public ?int $expirationTimestamp = null, + public ?string $parent = null, ) { } }