From 28e5d967ca3cea1badb4861e0a34a564c4256bfa Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo <1102197+priyadi@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:34:16 +0700 Subject: [PATCH] revert: "chore: change coding style to @PhpCsFixer:risky (#188)" This reverts commit 1be13266bbce82e392d741d99ecf55be72bf9a93. --- .php-cs-fixer.dist.php | 24 +++++++++-- CHANGELOG.md | 4 -- composer.json | 2 +- .../src/Implementation/PagerNormalizer.php | 2 +- .../src/Util/IriHelper.php | 2 +- .../rekapager-contracts/src/PageInterface.php | 4 +- .../rekapager-core/src/Batch/BatchProcess.php | 4 +- .../src/Contracts/PagerItemInterface.php | 4 +- .../Pager/Internal/NullPagerUrlGenerator.php | 2 +- .../src/Pager/Internal/PagerItem.php | 6 +-- .../src/Pager/Internal/PagerUrlGenerator.php | 6 +-- .../src/Pager/Internal/ProximityPager.php | 4 +- .../src/Pager/Internal/ZeroProximityPager.php | 2 +- .../MissingPlaceholderInSQLException.php | 2 +- .../src/Contracts/KeysetPageIdentifier.php | 2 +- .../src/Batch/BatchCommand.php | 4 +- .../src/Batch/Internal/BatchTimer.php | 2 +- .../CommandBatchProcessorDecorator.php | 2 +- tests/src/App/Controller/DemoController.php | 10 ++--- ...tPageableNativeQueryAdapterNativeQuery.php | 4 +- ...NativeQueryAdapterNativeQueryRowValues.php | 4 +- ...BALQueryBuilderAdapterDBALQueryBuilder.php | 4 +- ...uilderAdapterDBALQueryBuilderRowValues.php | 4 +- ...ageableQueryBuilderAdapterQueryBuilder.php | 4 +- ...eryBuilderAdapterQueryBuilderRowValues.php | 4 +- ...setPageableSelectableAdapterCollection.php | 4 +- ...eableSelectableAdapterEntityRepository.php | 4 +- ...setPageableCollectionAdapterCollection.php | 4 +- ...BALQueryBuilderAdapterDBALQueryBuilder.php | 4 +- ...OffsetPageablePagerfantaAdapterAdapter.php | 4 +- ...ageableQueryBuilderAdapterQueryBuilder.php | 4 +- ...setPageableSelectableAdapterCollection.php | 4 +- ...PagerfantaSelectableAdapter_Collection.php | 4 +- .../Index/PagerfantaAdapterIndexByTest.php | 4 +- .../Index/QueryBuilderAdapterIndexByTest.php | 4 +- .../Index/SelectableAdapterIndexByTest.php | 4 +- .../IntegrationTests/Pageable/BatchTest.php | 12 +++--- .../Pageable/CountAwarePageableTest.php | 10 ++--- .../Pageable/DefaultPageableTest.php | 22 +++++----- .../Pageable/EmptyPageableTest.php | 4 +- .../Pageable/PageableTestCase.php | 2 +- .../Pager/KeysetPagerTest.php | 2 +- .../Pager/KeysetPagerTraversalTest.php | 10 ++--- .../Pager/OffsetPagerTest.php | 2 +- .../Pager/OffsetPagerWithCountTest.php | 2 +- .../IntegrationTests/Pager/PagerTestCase.php | 42 +++++++++---------- .../PagerFactory/PagerFactoryTest.php | 6 +-- tests/src/UnitTests/CountTest.php | 12 +++--- tests/src/UnitTests/KeysetPageableTest.php | 4 +- tests/src/UnitTests/OffsetPageableTest.php | 4 +- 50 files changed, 152 insertions(+), 138 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 19b5b27..95fecc9 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -7,10 +7,28 @@ $config = new PhpCsFixer\Config(); return $config->setRules([ - '@PhpCsFixer:risky' => true, - 'declare_strict_types' => true, - 'php_unit_strict' => false, + '@PSR12' => true, + 'array_syntax' => ['syntax' => 'short'], + // imports + 'fully_qualified_strict_types' => true, + 'global_namespace_import' => [ + 'import_classes' => false, + 'import_constants' => false, + 'import_functions' => false, + ], + 'no_leading_import_slash' => true, + 'no_unneeded_import_alias' => true, + 'no_unused_imports' => true, + 'ordered_imports' => [ + 'sort_algorithm' => 'alpha', + 'imports_order' => ['const', 'class', 'function'] + ], + 'single_line_after_imports' => true, + 'no_useless_else' => true, + 'no_useless_return' => true, + 'declare_strict_types' => true, + 'native_function_invocation' => ['include' => ['@compiler_optimized']], 'header_comment' => [ 'header' => <<collectionNormalizer->getSupportedTypes($format); diff --git a/packages/rekapager-api-platform/src/Util/IriHelper.php b/packages/rekapager-api-platform/src/Util/IriHelper.php index 7f2ffd1..33dd065 100644 --- a/packages/rekapager-api-platform/src/Util/IriHelper.php +++ b/packages/rekapager-api-platform/src/Util/IriHelper.php @@ -63,7 +63,7 @@ public static function createIri(array $parts, array $parameters, ?string $pageP $parameters[$pageParameterName] = $encodedPageIdentifier; } - $query = http_build_query($parameters, '', '&', PHP_QUERY_RFC3986); + $query = http_build_query($parameters, '', '&', \PHP_QUERY_RFC3986); $parts['query'] = preg_replace('/%5B\d+%5D/', '%5B%5D', $query); $url = ''; diff --git a/packages/rekapager-contracts/src/PageInterface.php b/packages/rekapager-contracts/src/PageInterface.php index d3ab08e..572841c 100644 --- a/packages/rekapager-contracts/src/PageInterface.php +++ b/packages/rekapager-contracts/src/PageInterface.php @@ -66,14 +66,14 @@ public function getItemsPerPage(): int; * * @return null|PageInterface */ - public function getNextPage(): ?self; + public function getNextPage(): ?PageInterface; /** * Gets the previous page if it exists. * * @return null|PageInterface */ - public function getPreviousPage(): ?self; + public function getPreviousPage(): ?PageInterface; /** * Gets n next pages diff --git a/packages/rekapager-core/src/Batch/BatchProcess.php b/packages/rekapager-core/src/Batch/BatchProcess.php index a213413..11b5d85 100644 --- a/packages/rekapager-core/src/Batch/BatchProcess.php +++ b/packages/rekapager-core/src/Batch/BatchProcess.php @@ -42,7 +42,7 @@ public function __construct( ) { } - public function stop(): bool + final public function stop(): bool { if ($this->stopFlag === false) { $this->stopFlag = true; @@ -56,7 +56,7 @@ public function stop(): bool /** * @param int<1,max>|null $pageSize */ - public function run( + final public function run( ?string $resume = null, ?int $pageSize = null, ?int $timeLimit = null, diff --git a/packages/rekapager-core/src/Contracts/PagerItemInterface.php b/packages/rekapager-core/src/Contracts/PagerItemInterface.php index 3986c4d..ebf3e6c 100644 --- a/packages/rekapager-core/src/Contracts/PagerItemInterface.php +++ b/packages/rekapager-core/src/Contracts/PagerItemInterface.php @@ -33,12 +33,12 @@ public function isDisabled(): bool; /** * @return null|PagerItemInterface */ - public function getNextPage(): ?self; + public function getNextPage(): ?PagerItemInterface; /** * @return null|PagerItemInterface */ - public function getPreviousPage(): ?self; + public function getPreviousPage(): ?PagerItemInterface; /** * Gets n next pages diff --git a/packages/rekapager-core/src/Pager/Internal/NullPagerUrlGenerator.php b/packages/rekapager-core/src/Pager/Internal/NullPagerUrlGenerator.php index 40587e5..47f8425 100644 --- a/packages/rekapager-core/src/Pager/Internal/NullPagerUrlGenerator.php +++ b/packages/rekapager-core/src/Pager/Internal/NullPagerUrlGenerator.php @@ -18,7 +18,7 @@ /** * @internal */ -final class NullPagerUrlGenerator implements PagerUrlGeneratorInterface +class NullPagerUrlGenerator implements PagerUrlGeneratorInterface { #[\Override] public function generateUrl(PageInterface $page): ?string diff --git a/packages/rekapager-core/src/Pager/Internal/PagerItem.php b/packages/rekapager-core/src/Pager/Internal/PagerItem.php index cee392b..15dc251 100644 --- a/packages/rekapager-core/src/Pager/Internal/PagerItem.php +++ b/packages/rekapager-core/src/Pager/Internal/PagerItem.php @@ -158,13 +158,13 @@ public function getUrl(): ?string * @param PageInterface $page * @return PagerItem */ - private function decorate(PageInterface $page): self + private function decorate(PageInterface $page): PagerItem { - if ($page instanceof self) { + if ($page instanceof PagerItem) { return $page; } - return new self( + return new PagerItem( wrapped: $page, pagerUrlGenerator: $this->pagerUrlGenerator, ); diff --git a/packages/rekapager-core/src/Pager/Internal/PagerUrlGenerator.php b/packages/rekapager-core/src/Pager/Internal/PagerUrlGenerator.php index bc0b2cb..64b4f8c 100644 --- a/packages/rekapager-core/src/Pager/Internal/PagerUrlGenerator.php +++ b/packages/rekapager-core/src/Pager/Internal/PagerUrlGenerator.php @@ -21,14 +21,14 @@ /** * @internal */ -final readonly class PagerUrlGenerator implements PagerUrlGeneratorInterface +class PagerUrlGenerator implements PagerUrlGeneratorInterface { /** * @param PageIdentifierEncoderInterface $pageIdentifierEncoder */ public function __construct( - private PageUrlGeneratorInterface $pageUrlGenerator, - private PageIdentifierEncoderInterface $pageIdentifierEncoder, + private readonly PageUrlGeneratorInterface $pageUrlGenerator, + private readonly PageIdentifierEncoderInterface $pageIdentifierEncoder, ) { } diff --git a/packages/rekapager-core/src/Pager/Internal/ProximityPager.php b/packages/rekapager-core/src/Pager/Internal/ProximityPager.php index 9e57a56..c763695 100644 --- a/packages/rekapager-core/src/Pager/Internal/ProximityPager.php +++ b/packages/rekapager-core/src/Pager/Internal/ProximityPager.php @@ -267,8 +267,8 @@ public function __construct( if ( $lastPageFromNextNeighboringPages !== false && $this->hasHiddenPagesAfter - && null !== ($lastPageNumber = $this->lastPage?->getPageNumber()) - && null !== ($lastPageFromNextNeighboringPagesNumber = $lastPageFromNextNeighboringPages->getPageNumber()) + && !\is_null($lastPageNumber = $this->lastPage?->getPageNumber()) + && !\is_null($lastPageFromNextNeighboringPagesNumber = $lastPageFromNextNeighboringPages->getPageNumber()) && $lastPageFromNextNeighboringPagesNumber - $lastPageNumber === -2 && $secondLastPage = array_shift($nextPages) ) { diff --git a/packages/rekapager-core/src/Pager/Internal/ZeroProximityPager.php b/packages/rekapager-core/src/Pager/Internal/ZeroProximityPager.php index 5650f3c..a44ab09 100644 --- a/packages/rekapager-core/src/Pager/Internal/ZeroProximityPager.php +++ b/packages/rekapager-core/src/Pager/Internal/ZeroProximityPager.php @@ -25,7 +25,7 @@ * @implements PagerInterface * @internal */ -final class ZeroProximityPager implements PagerInterface +class ZeroProximityPager implements PagerInterface { // // pager components diff --git a/packages/rekapager-doctrine-orm-adapter/src/Exception/MissingPlaceholderInSQLException.php b/packages/rekapager-doctrine-orm-adapter/src/Exception/MissingPlaceholderInSQLException.php index ece66e5..4812863 100644 --- a/packages/rekapager-doctrine-orm-adapter/src/Exception/MissingPlaceholderInSQLException.php +++ b/packages/rekapager-doctrine-orm-adapter/src/Exception/MissingPlaceholderInSQLException.php @@ -29,7 +29,7 @@ public function __construct( 'Missing placeholder "{{%s}}" in SQL variable "$%s". Required placeholders: %s', $template, $sqlVariable, - implode(', ', array_map(static fn (string $template): string => sprintf('"{{%s}}"', $template), $templates)) + implode(', ', array_map(fn (string $template): string => sprintf('"{{%s}}"', $template), $templates)) )); } } diff --git a/packages/rekapager-keyset-pagination/src/Contracts/KeysetPageIdentifier.php b/packages/rekapager-keyset-pagination/src/Contracts/KeysetPageIdentifier.php index 5239161..53e3635 100644 --- a/packages/rekapager-keyset-pagination/src/Contracts/KeysetPageIdentifier.php +++ b/packages/rekapager-keyset-pagination/src/Contracts/KeysetPageIdentifier.php @@ -40,7 +40,7 @@ public function __serialize(): array ]; } - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line public function __unserialize(array $data): void { $this->pageOffsetFromBoundary = $data['o']; diff --git a/packages/rekapager-symfony-bridge/src/Batch/BatchCommand.php b/packages/rekapager-symfony-bridge/src/Batch/BatchCommand.php index c3274b6..10483fe 100644 --- a/packages/rekapager-symfony-bridge/src/Batch/BatchCommand.php +++ b/packages/rekapager-symfony-bridge/src/Batch/BatchCommand.php @@ -179,13 +179,13 @@ final protected function execute(InputInterface $input, OutputInterface $output) #[\Override] public function getSubscribedSignals(): array { - return [SIGINT, SIGTERM]; + return [\SIGINT, \SIGTERM]; } #[\Override] public function handleSignal(int $signal, int|false $previousExitCode = 0): int|false { - if (SIGINT !== $signal && SIGTERM !== $signal) { + if (\SIGINT !== $signal && \SIGTERM !== $signal) { return false; } diff --git a/packages/rekapager-symfony-bridge/src/Batch/Internal/BatchTimer.php b/packages/rekapager-symfony-bridge/src/Batch/Internal/BatchTimer.php index f52c035..29d43c1 100644 --- a/packages/rekapager-symfony-bridge/src/Batch/Internal/BatchTimer.php +++ b/packages/rekapager-symfony-bridge/src/Batch/Internal/BatchTimer.php @@ -18,7 +18,7 @@ /** * @internal */ -final class BatchTimer +class BatchTimer { public const TIMER_PROCESS = 'process'; diff --git a/packages/rekapager-symfony-bridge/src/Batch/Internal/CommandBatchProcessorDecorator.php b/packages/rekapager-symfony-bridge/src/Batch/Internal/CommandBatchProcessorDecorator.php index 07844ec..48d967e 100644 --- a/packages/rekapager-symfony-bridge/src/Batch/Internal/CommandBatchProcessorDecorator.php +++ b/packages/rekapager-symfony-bridge/src/Batch/Internal/CommandBatchProcessorDecorator.php @@ -33,7 +33,7 @@ * @extends BatchProcessorDecorator * @internal */ -final class CommandBatchProcessorDecorator extends BatchProcessorDecorator +class CommandBatchProcessorDecorator extends BatchProcessorDecorator { private readonly BatchTimer $timer; diff --git a/tests/src/App/Controller/DemoController.php b/tests/src/App/Controller/DemoController.php index 0ee8319..35ee9ec 100644 --- a/tests/src/App/Controller/DemoController.php +++ b/tests/src/App/Controller/DemoController.php @@ -102,7 +102,7 @@ public function page( $dumper->setTheme('light'); - $output = fopen('php://memory', 'r+') ?: throw new \RuntimeException('Failed to open memory stream'); + $output = fopen('php://memory', 'r+b') ?: throw new \RuntimeException('Failed to open memory stream'); $dumper->dump($cloner->cloneVar($pageIdentifier), $output); $output = stream_get_contents($output, -1, 0); @@ -135,7 +135,7 @@ public function batch( setName: 'medium', ); - // highlight-start + // @highlight-start $output = '
    '; @@ -182,7 +182,7 @@ public function batch( } $output .= '
'; - // highlight-end + // @highlight-end $title = $pageableGenerator->getTitle(); @@ -216,13 +216,13 @@ private function getSourceCode(string $class): string } $contents = preg_replace( - '|^.*//\s+highlight-start\n|s', + '|^.*//\s+@highlight-start\n|s', '', $contents, ) ?? throw new \RuntimeException('Regex fail'); $contents = preg_replace( - '|\n\s+//\s+highlight-end.*\n$|s', + '|\n\s+//\s+@highlight-end.*\n$|s', '', $contents, ) ?? throw new \RuntimeException('Regex fail'); diff --git a/tests/src/App/PageableGenerator/KeySetPageableNativeQueryAdapterNativeQuery.php b/tests/src/App/PageableGenerator/KeySetPageableNativeQueryAdapterNativeQuery.php index 175a352..f73d49a 100644 --- a/tests/src/App/PageableGenerator/KeySetPageableNativeQueryAdapterNativeQuery.php +++ b/tests/src/App/PageableGenerator/KeySetPageableNativeQueryAdapterNativeQuery.php @@ -52,7 +52,7 @@ public function generatePageable( string $setName, ?int $pageLimit = null, ): PageableInterface { - // highlight-start + // @highlight-start $resultSetMapping = new ResultSetMappingBuilder($this->entityManager); $resultSetMapping->addRootEntityFromClassMetadata(Post::class, 'p'); @@ -91,7 +91,7 @@ public function generatePageable( itemsPerPage: $itemsPerPage, count: $count, ); - // highlight-end + // @highlight-end // @phpstan-ignore-next-line return $pageable; diff --git a/tests/src/App/PageableGenerator/KeySetPageableNativeQueryAdapterNativeQueryRowValues.php b/tests/src/App/PageableGenerator/KeySetPageableNativeQueryAdapterNativeQueryRowValues.php index 10f077c..3749f37 100644 --- a/tests/src/App/PageableGenerator/KeySetPageableNativeQueryAdapterNativeQueryRowValues.php +++ b/tests/src/App/PageableGenerator/KeySetPageableNativeQueryAdapterNativeQueryRowValues.php @@ -53,7 +53,7 @@ public function generatePageable( string $setName, ?int $pageLimit = null, ): PageableInterface { - // highlight-start + // @highlight-start $resultSetMapping = new ResultSetMappingBuilder($this->entityManager); $resultSetMapping->addRootEntityFromClassMetadata(Post::class, 'p'); @@ -93,7 +93,7 @@ public function generatePageable( itemsPerPage: $itemsPerPage, count: $count, ); - // highlight-end + // @highlight-end // @phpstan-ignore-next-line return $pageable; diff --git a/tests/src/App/PageableGenerator/KeysetPageableDBALQueryBuilderAdapterDBALQueryBuilder.php b/tests/src/App/PageableGenerator/KeysetPageableDBALQueryBuilderAdapterDBALQueryBuilder.php index db7c476..e6d3dfa 100644 --- a/tests/src/App/PageableGenerator/KeysetPageableDBALQueryBuilderAdapterDBALQueryBuilder.php +++ b/tests/src/App/PageableGenerator/KeysetPageableDBALQueryBuilderAdapterDBALQueryBuilder.php @@ -49,7 +49,7 @@ public function generatePageable( string $setName, ?int $pageLimit = null, ): PageableInterface { - // highlight-start + // @highlight-start $queryBuilder = $this->connection ->createQueryBuilder() ->select('p.id', 'p.date', 'p.title', 'p.content', 'p.category') @@ -72,7 +72,7 @@ public function generatePageable( itemsPerPage: $itemsPerPage, count: $count, ); - // highlight-end + // @highlight-end // @phpstan-ignore-next-line return $pageable; diff --git a/tests/src/App/PageableGenerator/KeysetPageableDBALQueryBuilderAdapterDBALQueryBuilderRowValues.php b/tests/src/App/PageableGenerator/KeysetPageableDBALQueryBuilderAdapterDBALQueryBuilderRowValues.php index 98c0215..7ff4564 100644 --- a/tests/src/App/PageableGenerator/KeysetPageableDBALQueryBuilderAdapterDBALQueryBuilderRowValues.php +++ b/tests/src/App/PageableGenerator/KeysetPageableDBALQueryBuilderAdapterDBALQueryBuilderRowValues.php @@ -50,7 +50,7 @@ public function generatePageable( string $setName, ?int $pageLimit = null, ): PageableInterface { - // highlight-start + // @highlight-start $queryBuilder = $this->connection ->createQueryBuilder() ->select('p.id', 'p.date', 'p.title', 'p.content', 'p.category') @@ -74,7 +74,7 @@ public function generatePageable( itemsPerPage: $itemsPerPage, count: $count, ); - // highlight-end + // @highlight-end // @phpstan-ignore-next-line return $pageable; diff --git a/tests/src/App/PageableGenerator/KeysetPageableQueryBuilderAdapterQueryBuilder.php b/tests/src/App/PageableGenerator/KeysetPageableQueryBuilderAdapterQueryBuilder.php index 12c5432..60b86d6 100644 --- a/tests/src/App/PageableGenerator/KeysetPageableQueryBuilderAdapterQueryBuilder.php +++ b/tests/src/App/PageableGenerator/KeysetPageableQueryBuilderAdapterQueryBuilder.php @@ -49,7 +49,7 @@ public function generatePageable( string $setName, ?int $pageLimit = null, ): PageableInterface { - // highlight-start + // @highlight-start $queryBuilder = $this->postRepository ->createQueryBuilder('p') ->where('p.setName = :setName') @@ -71,7 +71,7 @@ public function generatePageable( itemsPerPage: $itemsPerPage, count: $count, ); - // highlight-end + // @highlight-end // @phpstan-ignore-next-line return $pageable; diff --git a/tests/src/App/PageableGenerator/KeysetPageableQueryBuilderAdapterQueryBuilderRowValues.php b/tests/src/App/PageableGenerator/KeysetPageableQueryBuilderAdapterQueryBuilderRowValues.php index 65ddad4..1748122 100644 --- a/tests/src/App/PageableGenerator/KeysetPageableQueryBuilderAdapterQueryBuilderRowValues.php +++ b/tests/src/App/PageableGenerator/KeysetPageableQueryBuilderAdapterQueryBuilderRowValues.php @@ -50,7 +50,7 @@ public function generatePageable( string $setName, ?int $pageLimit = null, ): PageableInterface { - // highlight-start + // @highlight-start $queryBuilder = $this->postRepository ->createQueryBuilder('p') ->where('p.setName = :setName') @@ -73,7 +73,7 @@ public function generatePageable( itemsPerPage: $itemsPerPage, count: $count, ); - // highlight-end + // @highlight-end // @phpstan-ignore-next-line return $pageable; diff --git a/tests/src/App/PageableGenerator/KeysetPageableSelectableAdapterCollection.php b/tests/src/App/PageableGenerator/KeysetPageableSelectableAdapterCollection.php index 0809a9d..a327a54 100644 --- a/tests/src/App/PageableGenerator/KeysetPageableSelectableAdapterCollection.php +++ b/tests/src/App/PageableGenerator/KeysetPageableSelectableAdapterCollection.php @@ -55,7 +55,7 @@ public function generatePageable( throw new \RuntimeException('No user found'); } - // highlight-start + // @highlight-start $selectable = $user->getPosts(); $criteria = Criteria::create() @@ -77,7 +77,7 @@ public function generatePageable( itemsPerPage: $itemsPerPage, count: $count, ); - // highlight-end + // @highlight-end // @phpstan-ignore-next-line return $pageable; diff --git a/tests/src/App/PageableGenerator/KeysetPageableSelectableAdapterEntityRepository.php b/tests/src/App/PageableGenerator/KeysetPageableSelectableAdapterEntityRepository.php index 3102d81..6e0e8dc 100644 --- a/tests/src/App/PageableGenerator/KeysetPageableSelectableAdapterEntityRepository.php +++ b/tests/src/App/PageableGenerator/KeysetPageableSelectableAdapterEntityRepository.php @@ -50,7 +50,7 @@ public function generatePageable( string $setName, ?int $pageLimit = null, ): PageableInterface { - // highlight-start + // @highlight-start $selectable = $this->postRepository; $criteria = Criteria::create() @@ -72,7 +72,7 @@ public function generatePageable( itemsPerPage: $itemsPerPage, count: $count, ); - // highlight-end + // @highlight-end return $pageable; } diff --git a/tests/src/App/PageableGenerator/OffsetPageableCollectionAdapterCollection.php b/tests/src/App/PageableGenerator/OffsetPageableCollectionAdapterCollection.php index 3a43fbc..2d30668 100644 --- a/tests/src/App/PageableGenerator/OffsetPageableCollectionAdapterCollection.php +++ b/tests/src/App/PageableGenerator/OffsetPageableCollectionAdapterCollection.php @@ -55,7 +55,7 @@ public function generatePageable( throw new \RuntimeException('No user found'); } - // highlight-start + // @highlight-start // LazyMatchingCollection is part of rekalogika/doctrine-collections-decorator package $lazyPosts = new LazyMatchingCollection($user->getPosts()); $filteredPosts = $lazyPosts->matching( @@ -70,7 +70,7 @@ public function generatePageable( count: $count, pageLimit: $pageLimit, ); - // highlight-end + // @highlight-end // @phpstan-ignore-next-line return $pageable; diff --git a/tests/src/App/PageableGenerator/OffsetPageableDBALQueryBuilderAdapterDBALQueryBuilder.php b/tests/src/App/PageableGenerator/OffsetPageableDBALQueryBuilderAdapterDBALQueryBuilder.php index 0f9ee4c..d024a17 100644 --- a/tests/src/App/PageableGenerator/OffsetPageableDBALQueryBuilderAdapterDBALQueryBuilder.php +++ b/tests/src/App/PageableGenerator/OffsetPageableDBALQueryBuilderAdapterDBALQueryBuilder.php @@ -50,7 +50,7 @@ public function generatePageable( string $setName, ?int $pageLimit = null, ): PageableInterface { - // highlight-start + // @highlight-start $queryBuilder = $this->connection ->createQueryBuilder() ->select('p.id', 'p.date', 'p.title', 'p.content', 'p.category') @@ -74,7 +74,7 @@ public function generatePageable( count: $count, pageLimit: $pageLimit, ); - // highlight-end + // @highlight-end // @phpstan-ignore-next-line return $pageable; diff --git a/tests/src/App/PageableGenerator/OffsetPageablePagerfantaAdapterAdapter.php b/tests/src/App/PageableGenerator/OffsetPageablePagerfantaAdapterAdapter.php index fd0e696..ab21d89 100644 --- a/tests/src/App/PageableGenerator/OffsetPageablePagerfantaAdapterAdapter.php +++ b/tests/src/App/PageableGenerator/OffsetPageablePagerfantaAdapterAdapter.php @@ -55,7 +55,7 @@ public function generatePageable( throw new \RuntimeException('No user found'); } - // highlight-start + // @highlight-start $criteria = Criteria::create() ->where(Criteria::expr()->eq('setName', $setName)); @@ -71,7 +71,7 @@ public function generatePageable( count: $count, pageLimit: $pageLimit, ); - // highlight-end + // @highlight-end // @phpstan-ignore-next-line return $pageable; diff --git a/tests/src/App/PageableGenerator/OffsetPageableQueryBuilderAdapterQueryBuilder.php b/tests/src/App/PageableGenerator/OffsetPageableQueryBuilderAdapterQueryBuilder.php index 992cfd3..5a66282 100644 --- a/tests/src/App/PageableGenerator/OffsetPageableQueryBuilderAdapterQueryBuilder.php +++ b/tests/src/App/PageableGenerator/OffsetPageableQueryBuilderAdapterQueryBuilder.php @@ -56,7 +56,7 @@ public function generatePageable( throw new \RuntimeException('No user found'); } - // highlight-start + // @highlight-start $queryBuilder = $this->postRepository ->createQueryBuilder('p') ->where('p.setName = :setName') @@ -78,7 +78,7 @@ public function generatePageable( count: $count, pageLimit: $pageLimit, ); - // highlight-end + // @highlight-end // @phpstan-ignore-next-line return $pageable; diff --git a/tests/src/App/PageableGenerator/OffsetPageableSelectableAdapterCollection.php b/tests/src/App/PageableGenerator/OffsetPageableSelectableAdapterCollection.php index 1b64098..ab807bb 100644 --- a/tests/src/App/PageableGenerator/OffsetPageableSelectableAdapterCollection.php +++ b/tests/src/App/PageableGenerator/OffsetPageableSelectableAdapterCollection.php @@ -55,7 +55,7 @@ public function generatePageable( throw new \RuntimeException('No user found'); } - // highlight-start + // @highlight-start $selectable = $user->getPosts(); $criteria = Criteria::create() @@ -78,7 +78,7 @@ public function generatePageable( count: $count, pageLimit: $pageLimit, ); - // highlight-end + // @highlight-end // @phpstan-ignore-next-line return $pageable; diff --git a/tests/src/App/PageableGenerator/PagerfantaPageable_Pagerfanta_PagerfantaSelectableAdapter_Collection.php b/tests/src/App/PageableGenerator/PagerfantaPageable_Pagerfanta_PagerfantaSelectableAdapter_Collection.php index b8a014d..1496ec3 100644 --- a/tests/src/App/PageableGenerator/PagerfantaPageable_Pagerfanta_PagerfantaSelectableAdapter_Collection.php +++ b/tests/src/App/PageableGenerator/PagerfantaPageable_Pagerfanta_PagerfantaSelectableAdapter_Collection.php @@ -55,7 +55,7 @@ public function generatePageable( throw new \RuntimeException('No user found'); } - // highlight-start + // @highlight-start $criteria = Criteria::create() ->where(Criteria::expr()->eq('setName', $setName)); @@ -69,7 +69,7 @@ public function generatePageable( pageLimit: $pageLimit, indexBy: 'id', ); - // highlight-end + // @highlight-end // @phpstan-ignore-next-line return $pageable; diff --git a/tests/src/IntegrationTests/Index/PagerfantaAdapterIndexByTest.php b/tests/src/IntegrationTests/Index/PagerfantaAdapterIndexByTest.php index 5f652b0..c9d00fe 100644 --- a/tests/src/IntegrationTests/Index/PagerfantaAdapterIndexByTest.php +++ b/tests/src/IntegrationTests/Index/PagerfantaAdapterIndexByTest.php @@ -51,8 +51,8 @@ public function testIndexBy(): void /** @var Post $post */ foreach ($pageable->getFirstPage() as $key => $post) { - self::assertInstanceOf(Post::class, $post); - self::assertEquals($key, $post->getId()); + static::assertInstanceOf(Post::class, $post); + static::assertEquals($key, $post->getId()); } } diff --git a/tests/src/IntegrationTests/Index/QueryBuilderAdapterIndexByTest.php b/tests/src/IntegrationTests/Index/QueryBuilderAdapterIndexByTest.php index cf88ed1..f850e89 100644 --- a/tests/src/IntegrationTests/Index/QueryBuilderAdapterIndexByTest.php +++ b/tests/src/IntegrationTests/Index/QueryBuilderAdapterIndexByTest.php @@ -58,8 +58,8 @@ public function testIndexBy(): void /** @var Post $post */ foreach ($pageable->getFirstPage() as $key => $post) { - self::assertInstanceOf(Post::class, $post); - self::assertEquals($key, $post->getId()); + static::assertInstanceOf(Post::class, $post); + static::assertEquals($key, $post->getId()); } } diff --git a/tests/src/IntegrationTests/Index/SelectableAdapterIndexByTest.php b/tests/src/IntegrationTests/Index/SelectableAdapterIndexByTest.php index 4168c91..9c64ea0 100644 --- a/tests/src/IntegrationTests/Index/SelectableAdapterIndexByTest.php +++ b/tests/src/IntegrationTests/Index/SelectableAdapterIndexByTest.php @@ -52,8 +52,8 @@ public function testIndexBy(): void /** @var Post $post */ foreach ($pageable->getFirstPage() as $key => $post) { - self::assertInstanceOf(Post::class, $post); - self::assertEquals($key, $post->getId()); + static::assertInstanceOf(Post::class, $post); + static::assertEquals($key, $post->getId()); } } diff --git a/tests/src/IntegrationTests/Pageable/BatchTest.php b/tests/src/IntegrationTests/Pageable/BatchTest.php index 3c784b8..c0581b7 100644 --- a/tests/src/IntegrationTests/Pageable/BatchTest.php +++ b/tests/src/IntegrationTests/Pageable/BatchTest.php @@ -45,9 +45,9 @@ public function testBatch(string $pageableGeneratorClass): void $pagesCount++; } - self::assertSame(1003, $itemsCount); - self::assertSame(21, $pagesCount); - self::assertCount(1003, $ids); + static::assertSame(1003, $itemsCount); + static::assertSame(21, $pagesCount); + static::assertCount(1003, $ids); } #[DataProviderExternal(PageableGeneratorProvider::class, 'all')] @@ -89,8 +89,8 @@ public function testBatchResuming(string $pageableGeneratorClass): void $pagesCount++; } - self::assertSame(1003, $itemsCount); - self::assertSame(21, $pagesCount); - self::assertCount(1003, $ids); + static::assertSame(1003, $itemsCount); + static::assertSame(21, $pagesCount); + static::assertCount(1003, $ids); } } diff --git a/tests/src/IntegrationTests/Pageable/CountAwarePageableTest.php b/tests/src/IntegrationTests/Pageable/CountAwarePageableTest.php index 8527bc9..91888f9 100644 --- a/tests/src/IntegrationTests/Pageable/CountAwarePageableTest.php +++ b/tests/src/IntegrationTests/Pageable/CountAwarePageableTest.php @@ -30,8 +30,8 @@ public function testNextUntilLastPage(string $pageableGeneratorClass): void $pageable = $this->createPageableFromGenerator($pageableGeneratorClass); $page = $pageable->getFirstPage(); $lastPage = $pageable->getLastPage(); - self::assertNotNull($lastPage); - self::assertCount(3, $lastPage); + static::assertNotNull($lastPage); + static::assertCount(3, $lastPage); $firstPage = $page; while (true) { @@ -44,8 +44,8 @@ public function testNextUntilLastPage(string $pageableGeneratorClass): void $page = $nextPage; } - self::assertCount(3, $page); - self::assertEquals(iterator_to_array($lastPage), iterator_to_array($page)); + static::assertCount(3, $page); + static::assertEquals(iterator_to_array($lastPage), iterator_to_array($page)); while (true) { $previousPage = $page->getPreviousPage(); @@ -57,6 +57,6 @@ public function testNextUntilLastPage(string $pageableGeneratorClass): void $page = $previousPage; } - self::assertEquals(iterator_to_array($firstPage), iterator_to_array($page)); + static::assertEquals(iterator_to_array($firstPage), iterator_to_array($page)); } } diff --git a/tests/src/IntegrationTests/Pageable/DefaultPageableTest.php b/tests/src/IntegrationTests/Pageable/DefaultPageableTest.php index 38c873e..56b9b99 100644 --- a/tests/src/IntegrationTests/Pageable/DefaultPageableTest.php +++ b/tests/src/IntegrationTests/Pageable/DefaultPageableTest.php @@ -24,11 +24,11 @@ public function testFirstPage(string $pageableGeneratorClass): void $pageable = $this->createPageableFromGenerator($pageableGeneratorClass); $firstPage = $pageable->getFirstPage(); $itemsPerPage = $pageable->getItemsPerPage(); - self::assertEquals($itemsPerPage, $firstPage->count()); + static::assertEquals($itemsPerPage, $firstPage->count()); $pageIdentifier = $firstPage->getPageIdentifier(); $firstPage2 = $pageable->getPageByIdentifier($pageIdentifier); - self::assertEquals(iterator_to_array($firstPage), iterator_to_array($firstPage2)); + static::assertEquals(iterator_to_array($firstPage), iterator_to_array($firstPage2)); } #[DataProviderExternal(PageableGeneratorProvider::class, 'all')] @@ -37,22 +37,22 @@ public function testNextPagePreviousPage(string $pageableGeneratorClass): void $pageable = $this->createPageableFromGenerator($pageableGeneratorClass); $firstPage = $pageable->getFirstPage(); $secondPage = $firstPage->getNextPage(); - self::assertNotNull($secondPage); + static::assertNotNull($secondPage); $secondPageIdentifier = $secondPage->getPageIdentifier(); $secondPage2 = $pageable->getPageByIdentifier($secondPageIdentifier); - self::assertEquals(iterator_to_array($secondPage), iterator_to_array($secondPage2)); + static::assertEquals(iterator_to_array($secondPage), iterator_to_array($secondPage2)); $thirdPage = $secondPage->getNextPage(); - self::assertNotNull($thirdPage); + static::assertNotNull($thirdPage); $secondPage2 = $thirdPage->getPreviousPage(); - self::assertNotNull($secondPage2); + static::assertNotNull($secondPage2); $firstPage2 = $secondPage2->getPreviousPage(); - self::assertNotNull($firstPage2); + static::assertNotNull($firstPage2); - self::assertEquals(iterator_to_array($secondPage), iterator_to_array($secondPage2)); - self::assertEquals(iterator_to_array($firstPage), iterator_to_array($firstPage2)); + static::assertEquals(iterator_to_array($secondPage), iterator_to_array($secondPage2)); + static::assertEquals(iterator_to_array($firstPage), iterator_to_array($firstPage2)); } #[DataProviderExternal(PageableGeneratorProvider::class, 'all')] @@ -72,7 +72,7 @@ public function testNextUntilLastPage(string $pageableGeneratorClass): void $page = $nextPage; } - self::assertCount(3, $page); + static::assertCount(3, $page); while (true) { $previousPage = $page->getPreviousPage(); @@ -84,6 +84,6 @@ public function testNextUntilLastPage(string $pageableGeneratorClass): void $page = $previousPage; } - self::assertEquals(iterator_to_array($firstPage), iterator_to_array($page)); + static::assertEquals(iterator_to_array($firstPage), iterator_to_array($page)); } } diff --git a/tests/src/IntegrationTests/Pageable/EmptyPageableTest.php b/tests/src/IntegrationTests/Pageable/EmptyPageableTest.php index e5e0e86..e75c97d 100644 --- a/tests/src/IntegrationTests/Pageable/EmptyPageableTest.php +++ b/tests/src/IntegrationTests/Pageable/EmptyPageableTest.php @@ -29,7 +29,7 @@ public function testFirstPage(string $pageableGeneratorClass): void { $pageable = $this->createPageableFromGenerator($pageableGeneratorClass); $page = $pageable->getFirstPage(); - self::assertCount(0, $page); + static::assertCount(0, $page); } #[DataProviderExternal(PageableGeneratorProvider::class, 'all')] @@ -38,6 +38,6 @@ public function testNextPage(string $pageableGeneratorClass): void $pageable = $this->createPageableFromGenerator($pageableGeneratorClass); $page = $pageable->getFirstPage(); $nextPage = $page->getNextPage(); - self::assertNull($nextPage); + static::assertNull($nextPage); } } diff --git a/tests/src/IntegrationTests/Pageable/PageableTestCase.php b/tests/src/IntegrationTests/Pageable/PageableTestCase.php index 2d52673..a670fe6 100644 --- a/tests/src/IntegrationTests/Pageable/PageableTestCase.php +++ b/tests/src/IntegrationTests/Pageable/PageableTestCase.php @@ -56,7 +56,7 @@ public function createPageableFromGenerator(string $pageableGeneratorClass): Pag $pageableGenerator = self::getContainer() ->get($pageableGeneratorClass); - self::assertInstanceOf(PageableGeneratorInterface::class, $pageableGenerator); + static::assertInstanceOf(PageableGeneratorInterface::class, $pageableGenerator); return $pageableGenerator->generatePageable( itemsPerPage: $this->getItemsPerPage(), diff --git a/tests/src/IntegrationTests/Pager/KeysetPagerTest.php b/tests/src/IntegrationTests/Pager/KeysetPagerTest.php index 76b9dea..085b30c 100644 --- a/tests/src/IntegrationTests/Pager/KeysetPagerTest.php +++ b/tests/src/IntegrationTests/Pager/KeysetPagerTest.php @@ -410,7 +410,7 @@ public function testThirdPageByIterationAndJump(string $pageableGeneratorClass): $firstPage = $pageable->getFirstPage(); $nextPages = $firstPage->getNextPages(2); $pageByJump = $nextPages[1] ?? null; - self::assertNotNull($pageByJump); + static::assertNotNull($pageByJump); $pagerByJump = $this->createPagerFromPage($pageByJump); diff --git a/tests/src/IntegrationTests/Pager/KeysetPagerTraversalTest.php b/tests/src/IntegrationTests/Pager/KeysetPagerTraversalTest.php index fd7c87d..4868ff6 100644 --- a/tests/src/IntegrationTests/Pager/KeysetPagerTraversalTest.php +++ b/tests/src/IntegrationTests/Pager/KeysetPagerTraversalTest.php @@ -33,12 +33,12 @@ public function testLastPageFromSecondFromLastPage(string $pageableGeneratorClas $nextPageIdentifier = $nextPage?->getPageIdentifier(); $lastPageIdentifier = $lastPage?->getPageIdentifier(); - self::assertEquals($lastPageIdentifier, $nextPageIdentifier); + static::assertEquals($lastPageIdentifier, $nextPageIdentifier); - self::assertNotNull($nextPage); - self::assertInstanceOf(KeysetPageIdentifier::class, $nextPageIdentifier); - self::assertEquals(BoundaryType::Lower, $nextPageIdentifier->getBoundaryType()); - self::assertCount(3, $nextPage); + static::assertNotNull($nextPage); + static::assertInstanceOf(KeysetPageIdentifier::class, $nextPageIdentifier); + static::assertEquals(BoundaryType::Lower, $nextPageIdentifier->getBoundaryType()); + static::assertCount(3, $nextPage); } #[DataProviderExternal(PageableGeneratorProvider::class, 'keyset')] diff --git a/tests/src/IntegrationTests/Pager/OffsetPagerTest.php b/tests/src/IntegrationTests/Pager/OffsetPagerTest.php index a9a5170..e22a2a7 100644 --- a/tests/src/IntegrationTests/Pager/OffsetPagerTest.php +++ b/tests/src/IntegrationTests/Pager/OffsetPagerTest.php @@ -343,7 +343,7 @@ public function testThirdPageByIterationAndJump(string $pageableGeneratorClass): $firstPage = $pageable->getFirstPage(); $nextPages = $firstPage->getNextPages(2); $pageByJump = $nextPages[1] ?? null; - self::assertNotNull($pageByJump); + static::assertNotNull($pageByJump); $pagerByJump = $this->createPagerFromPage($pageByJump); diff --git a/tests/src/IntegrationTests/Pager/OffsetPagerWithCountTest.php b/tests/src/IntegrationTests/Pager/OffsetPagerWithCountTest.php index 7f55e8f..9b18cfc 100644 --- a/tests/src/IntegrationTests/Pager/OffsetPagerWithCountTest.php +++ b/tests/src/IntegrationTests/Pager/OffsetPagerWithCountTest.php @@ -349,7 +349,7 @@ public function testThirdPageByIterationAndJump(string $pageableGeneratorClass): $firstPage = $pageable->getFirstPage(); $nextPages = $firstPage->getNextPages(2); $pageByJump = $nextPages[1] ?? null; - self::assertNotNull($pageByJump); + static::assertNotNull($pageByJump); $pagerByJump = $this->createPagerFromPage($pageByJump); diff --git a/tests/src/IntegrationTests/Pager/PagerTestCase.php b/tests/src/IntegrationTests/Pager/PagerTestCase.php index 322dded..5f2681a 100644 --- a/tests/src/IntegrationTests/Pager/PagerTestCase.php +++ b/tests/src/IntegrationTests/Pager/PagerTestCase.php @@ -107,39 +107,39 @@ protected function assertPager( array $nextPageNumbers, int $currentCount, ): void { - self::assertEquals($proximity, $pager->getProximity()); - self::assertEquals($hasPrevious, $pager->getPreviousPage() !== null); - self::assertEquals($hasNext, $pager->getNextPage() !== null); - self::assertEquals($hasFirst, $pager->getFirstPage() !== null); - self::assertEquals($hasLast, $pager->getLastPage() !== null); - self::assertEquals($hasGapToFirstPage, $pager->hasGapToFirstPage()); - self::assertEquals($hasGapToLastPage, $pager->hasGapToLastPage()); - self::assertCount($numOfPreviousNeighboringPages, $pager->getPreviousNeighboringPages()); - self::assertCount($numOfNextNeighboringPages, $pager->getNextNeighboringPages()); - self::assertEquals($firstPageNumber, $pager->getFirstPage()?->getPageNumber()); - self::assertEquals($lastPageNumber, $pager->getLastPage()?->getPageNumber()); + static::assertEquals($proximity, $pager->getProximity()); + static::assertEquals($hasPrevious, $pager->getPreviousPage() !== null); + static::assertEquals($hasNext, $pager->getNextPage() !== null); + static::assertEquals($hasFirst, $pager->getFirstPage() !== null); + static::assertEquals($hasLast, $pager->getLastPage() !== null); + static::assertEquals($hasGapToFirstPage, $pager->hasGapToFirstPage()); + static::assertEquals($hasGapToLastPage, $pager->hasGapToLastPage()); + static::assertCount($numOfPreviousNeighboringPages, $pager->getPreviousNeighboringPages()); + static::assertCount($numOfNextNeighboringPages, $pager->getNextNeighboringPages()); + static::assertEquals($firstPageNumber, $pager->getFirstPage()?->getPageNumber()); + static::assertEquals($lastPageNumber, $pager->getLastPage()?->getPageNumber()); /** @psalm-suppress InvalidArgument */ $numbers = array_map( - static fn (PageInterface $page): ?int => $page->getPageNumber(), + fn (PageInterface $page): ?int => $page->getPageNumber(), iterator_to_array($pager->getPreviousNeighboringPages()) ); - self::assertEquals($previousPageNumbers, $numbers); + static::assertEquals($previousPageNumbers, $numbers); if ($currentPageNumber !== null) { - self::assertEquals($currentPageNumber, $pager->getCurrentPage()->getPageNumber()); + static::assertEquals($currentPageNumber, $pager->getCurrentPage()->getPageNumber()); } /** @psalm-suppress InvalidArgument */ $numbers = array_map( - static fn (PageInterface $page): ?int => $page->getPageNumber(), + fn (PageInterface $page): ?int => $page->getPageNumber(), iterator_to_array($pager->getNextNeighboringPages()) ); - self::assertEquals($nextPageNumbers, $numbers); + static::assertEquals($nextPageNumbers, $numbers); - self::assertEquals($currentCount, $pager->getCurrentPage()->count()); + static::assertEquals($currentCount, $pager->getCurrentPage()->count()); } /** @@ -156,7 +156,7 @@ protected function getNthPageFromBeginning( while ($n > 1) { $page = $page->getNextPage(); - self::assertNotNull($page); + static::assertNotNull($page); $n--; } @@ -177,11 +177,11 @@ protected function getNthPageFromEnd( while ($n > 1) { $page = $page?->getPreviousPage(); - self::assertNotNull($page); + static::assertNotNull($page); $n--; } - self::assertNotNull($page); + static::assertNotNull($page); return $page; } @@ -224,7 +224,7 @@ protected function getNthPageFromEndByIteration( while ($n > 1) { $page = $page->getPreviousPage(); - self::assertNotNull($page); + static::assertNotNull($page); $n--; } diff --git a/tests/src/IntegrationTests/PagerFactory/PagerFactoryTest.php b/tests/src/IntegrationTests/PagerFactory/PagerFactoryTest.php index 959e28f..80e6144 100644 --- a/tests/src/IntegrationTests/PagerFactory/PagerFactoryTest.php +++ b/tests/src/IntegrationTests/PagerFactory/PagerFactoryTest.php @@ -25,7 +25,7 @@ public function testPagerFactory(): void { $pagerFactory = static::getContainer()->get(PagerFactoryInterface::class); $pageable = $this->createPageableFromGenerator(OffsetPageableCollectionAdapterCollection::class); - self::assertInstanceOf(PagerFactoryInterface::class, $pagerFactory); + static::assertInstanceOf(PagerFactoryInterface::class, $pagerFactory); // without page parameter @@ -37,14 +37,14 @@ public function testPagerFactory(): void $pager = $pagerFactory->createPager($pageable, $request); $currentPage = $pager->getCurrentPage(); - self::assertEquals(1, $currentPage->getPageNumber()); + static::assertEquals(1, $currentPage->getPageNumber()); } public function testOutOfBound(): void { $pagerFactory = static::getContainer()->get(PagerFactoryInterface::class); $pageable = $this->createPageableFromGenerator(OffsetPageableCollectionAdapterCollection::class); - self::assertInstanceOf(PagerFactoryInterface::class, $pagerFactory); + static::assertInstanceOf(PagerFactoryInterface::class, $pagerFactory); $request = new Request( query: [ diff --git a/tests/src/UnitTests/CountTest.php b/tests/src/UnitTests/CountTest.php index 06ef472..9bd6fe2 100644 --- a/tests/src/UnitTests/CountTest.php +++ b/tests/src/UnitTests/CountTest.php @@ -33,7 +33,7 @@ class CountTest extends TestCase * @psalm-suppress MixedReturnTypeCoercion * @return iterable,PageableInterface,mixed}> */ - public static function provideNoCountCases(): iterable + public static function provider(): iterable { /** @var Collection&Selectable */ $collection = new ArrayCollection([ @@ -74,7 +74,7 @@ public static function provideNoCountCases(): iterable adapter: new SelectableAdapter( collection: $collection ), - count: static fn () => $collection->count(), + count: fn () => $collection->count(), ), 5, ]; @@ -109,7 +109,7 @@ public static function provideNoCountCases(): iterable adapter: new SelectableAdapter( collection: $collection ), - count: static fn () => $collection->count(), + count: fn () => $collection->count(), ), 5, ]; @@ -143,7 +143,7 @@ public static function provideNoCountCases(): iterable adapter: new PagerfantaAdapterAdapter( adapter: new PagerfantaSelectableAdapter($collection, Criteria::create()) ), - count: static fn () => $collection->count(), + count: fn () => $collection->count(), ), 5, ]; @@ -152,13 +152,13 @@ public static function provideNoCountCases(): iterable /** * @param Collection $collection * @param PageableInterface $pageable - * @dataProvider provideNoCountCases + * @dataProvider provider */ public function testNoCount( Collection $collection, PageableInterface $pageable, mixed $expected, ): void { - self::assertSame($expected, $pageable->getTotalItems()); + $this->assertSame($expected, $pageable->getTotalItems()); } } diff --git a/tests/src/UnitTests/KeysetPageableTest.php b/tests/src/UnitTests/KeysetPageableTest.php index 639c80d..76bc13b 100644 --- a/tests/src/UnitTests/KeysetPageableTest.php +++ b/tests/src/UnitTests/KeysetPageableTest.php @@ -49,7 +49,7 @@ public static function assertBoundedPage( self::assertInstanceOf(KeysetPageIdentifier::class, $pageIdentifier); self::assertEquals($boundaryType, $pageIdentifier->getBoundaryType()); self::assertEquals($boundaryValues, $pageIdentifier->getBoundaryValues()); - self::assertEquals($values, array_map(static fn (Entity $entity): int => $entity->getId(), array_values(iterator_to_array($page)))); + self::assertEquals($values, array_map(fn (Entity $entity): int => $entity->getId(), array_values(iterator_to_array($page)))); self::assertEquals($hasPreviousPage, null !== $page->getPreviousPage()); self::assertEquals($hasNextPage, null !== $page->getNextPage()); @@ -60,7 +60,7 @@ public static function assertBoundedPage( self::assertInstanceOf(KeysetPageIdentifier::class, $pageIdentifier); self::assertEquals($boundaryType, $pageIdentifier->getBoundaryType()); self::assertEquals($boundaryValues, $pageIdentifier->getBoundaryValues()); - self::assertEquals($values, array_map(static fn (Entity $entity): int => $entity->getId(), array_values(iterator_to_array($fromCollection)))); + self::assertEquals($values, array_map(fn (Entity $entity): int => $entity->getId(), array_values(iterator_to_array($fromCollection)))); self::assertEquals($hasPreviousPage, null !== $fromCollection->getPreviousPage()); self::assertEquals($hasNextPage, null !== $fromCollection->getNextPage()); } diff --git a/tests/src/UnitTests/OffsetPageableTest.php b/tests/src/UnitTests/OffsetPageableTest.php index 1624e6f..f49a5d2 100644 --- a/tests/src/UnitTests/OffsetPageableTest.php +++ b/tests/src/UnitTests/OffsetPageableTest.php @@ -49,7 +49,7 @@ public static function assertNumberedPage( self::assertEquals($itemsPerPage, $page->getItemsPerPage()); self::assertEquals($totalPages, $pageable->getTotalPages()); self::assertEquals($totalItems, $pageable->getTotalItems()); - self::assertEquals($values, array_map(static fn (Entity $entity): int => $entity->getId(), array_values(iterator_to_array($page)))); + self::assertEquals($values, array_map(fn (Entity $entity): int => $entity->getId(), array_values(iterator_to_array($page)))); self::assertEquals($hasPreviousPage, null !== $page->getPreviousPage()); self::assertEquals($hasNextPage, null !== $page->getNextPage()); @@ -59,7 +59,7 @@ public static function assertNumberedPage( self::assertEquals($itemsPerPage, $fromPageable->getItemsPerPage()); self::assertEquals($totalPages, $pageable->getTotalPages()); self::assertEquals($totalItems, $pageable->getTotalItems()); - self::assertEquals($values, array_map(static fn (Entity $entity): int => $entity->getId(), array_values(iterator_to_array($fromPageable)))); + self::assertEquals($values, array_map(fn (Entity $entity): int => $entity->getId(), array_values(iterator_to_array($fromPageable)))); self::assertEquals($hasPreviousPage, null !== $fromPageable->getPreviousPage()); self::assertEquals($hasNextPage, null !== $fromPageable->getNextPage()); }