From b658b286ae05c648ff29854145be3b01b9ab9ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Chru=C5=9Bciel?= Date: Mon, 11 Apr 2022 11:45:41 +0200 Subject: [PATCH] Revert "Revert "Bump Pagerfanta from 2.x to 3.x"" --- composer.json | 1 + phpstan.neon | 2 ++ .../DataTransformer/ResourceToIdentifierTransformer.php | 1 + .../Compiler/PagerfantaBridgePassTest.php | 2 +- .../spec/Controller/ResourcesCollectionProviderSpec.php | 8 ++++---- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 92439142b..87804e098 100644 --- a/composer.json +++ b/composer.json @@ -58,6 +58,7 @@ "doctrine/orm": "^2.5", "lchrusciel/api-test-case": "^5.0", "matthiasnoback/symfony-dependency-injection-test": "^4.2.1", + "pagerfanta/pagerfanta": "^3.0", "pamil/phpspec-skip-example-extension": "^4.2", "phpspec/phpspec": "^7.2", "phpspec/prophecy-phpunit": "^2.0", diff --git a/phpstan.neon b/phpstan.neon index f2959d6de..d579a1864 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -45,6 +45,8 @@ parameters: - '/Method Sylius\\Component\\Resource\\Model\\TimestampableInterface::setUpdatedAt\(\) has no return typehint specified./' - '/Method Symfony\\Component\\Routing\\RouteCollection::add\(\) invoked with 3 parameters, 2 required\./' - '/Method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) invoked with 2 parameters, 1 required\./' + - '/Parameter \#1 \$currentPage of method Pagerfanta\\Pagerfanta::setCurrentPage\(\) expects int<1, max>, int given\./' + - '/Parameter \#1 \$maxPerPage of method Pagerfanta\\Pagerfanta::setMaxPerPage\(\) expects int<1, max>, int given\./' - '/Parameter \#1 \$array[0-9]? of function array_multisort expects array, array\|int given\./' - '/Parameter \#2 \$class of static method Webmozart\\Assert\\Assert::isInstanceOf\(\) expects class-string, string given./' - '/Parameter \#1 \$objectOrClass of class ReflectionClass constructor expects class-string|object, object|string given./' diff --git a/src/Bundle/Form/DataTransformer/ResourceToIdentifierTransformer.php b/src/Bundle/Form/DataTransformer/ResourceToIdentifierTransformer.php index 4c13b0264..7035eb1f8 100644 --- a/src/Bundle/Form/DataTransformer/ResourceToIdentifierTransformer.php +++ b/src/Bundle/Form/DataTransformer/ResourceToIdentifierTransformer.php @@ -53,6 +53,7 @@ public function reverseTransform($value): ?ResourceInterface return null; } + /** @var ResourceInterface|null $resource */ $resource = $this->repository->findOneBy([$this->identifier => $value]); if (null === $resource) { throw new TransformationFailedException(sprintf( diff --git a/src/Bundle/Tests/DependencyInjection/Compiler/PagerfantaBridgePassTest.php b/src/Bundle/Tests/DependencyInjection/Compiler/PagerfantaBridgePassTest.php index 1836151d4..28240cccb 100644 --- a/src/Bundle/Tests/DependencyInjection/Compiler/PagerfantaBridgePassTest.php +++ b/src/Bundle/Tests/DependencyInjection/Compiler/PagerfantaBridgePassTest.php @@ -13,8 +13,8 @@ namespace Sylius\Bundle\ResourceBundle\Tests\DependencyInjection\Compiler; -use BabDev\PagerfantaBundle\Twig\PagerfantaExtension; use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase; +use Pagerfanta\Twig\Extension\PagerfantaExtension; use Pagerfanta\View\ViewFactory; use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\PagerfantaBridgePass; use Symfony\Component\DependencyInjection\ContainerBuilder; diff --git a/src/Bundle/spec/Controller/ResourcesCollectionProviderSpec.php b/src/Bundle/spec/Controller/ResourcesCollectionProviderSpec.php index 6a5c97dcb..e4baf04a0 100644 --- a/src/Bundle/spec/Controller/ResourcesCollectionProviderSpec.php +++ b/src/Bundle/spec/Controller/ResourcesCollectionProviderSpec.php @@ -76,7 +76,7 @@ function it_handles_Pagerfanta( $paginator->setMaxPerPage(5)->shouldBeCalled(); $paginator->setCurrentPage(6)->shouldBeCalled(); - $paginator->getCurrentPageResults()->shouldBeCalled(); + $paginator->getCurrentPageResults()->willReturn([]); $this->get($requestConfiguration, $repository)->shouldReturn($paginator); } @@ -109,7 +109,7 @@ function it_restricts_max_pagination_limit_based_on_grid_configuration( $paginator->setMaxPerPage(99)->shouldBeCalled(); $paginator->setCurrentPage(1)->shouldBeCalled(); - $paginator->getCurrentPageResults()->shouldBeCalled(); + $paginator->getCurrentPageResults()->willReturn([]); $this->get($requestConfiguration, $repository)->shouldReturn($gridView); } @@ -143,7 +143,7 @@ function it_creates_a_paginated_representation_for_pagerfanta_for_non_html_reque $paginator->setMaxPerPage(8)->shouldBeCalled(); $paginator->setCurrentPage(6)->shouldBeCalled(); - $paginator->getCurrentPageResults()->shouldBeCalled(); + $paginator->getCurrentPageResults()->willReturn([]); $pagerfantaRepresentationFactory->createRepresentation($paginator, Argument::type(Route::class))->willReturn($paginatedRepresentation); @@ -177,7 +177,7 @@ function it_handles_resource_grid_view( $paginator->setMaxPerPage(5)->shouldBeCalled(); $paginator->setCurrentPage(6)->shouldBeCalled(); - $paginator->getCurrentPageResults()->shouldBeCalled(); + $paginator->getCurrentPageResults()->willReturn([]); $this->get($requestConfiguration, $repository)->shouldReturn($resourceGridView); }