From 2dddef1017a757d68890ad7ec6e4e12f00e2ac7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Thu, 26 Aug 2021 20:45:35 +0200 Subject: [PATCH 1/6] qa: add PHP 8.1 to `composer.json` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- composer.json | 2 +- composer.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 9630440..44e8ec5 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ } }, "require": { - "php": "^7.3 || ~8.0.0", + "php": "^7.3 || ~8.0.0 || ~8.1.0", "laminas/laminas-zendframework-bridge": "^1.0", "mezzio/mezzio-router": "^3.0", "psr/container": "^1.0", diff --git a/composer.lock b/composer.lock index fd8c9a8..48da26e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "91c01236626a57564ed30d12fa432b51", + "content-hash": "055392157d5a0f81d52fc67f66a15695", "packages": [ { "name": "fig/http-message-util", @@ -4754,7 +4754,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.3 || ~8.0.0" + "php": "^7.3 || ~8.0.0 || ~8.1.0" }, "platform-dev": { "ext-json": "*" @@ -4762,5 +4762,5 @@ "platform-overrides": { "php": "7.4" }, - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.1.0" } From 685737e68fdfd944b842c2b1485eb67bfcac74b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Mon, 13 Sep 2021 22:54:47 +0200 Subject: [PATCH 2/6] qa: add/modify `.laminas-ci.json` to ignore PHP platform requirements for PHP 8.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- .laminas-ci.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .laminas-ci.json diff --git a/.laminas-ci.json b/.laminas-ci.json new file mode 100644 index 0000000..bce3fa2 --- /dev/null +++ b/.laminas-ci.json @@ -0,0 +1,5 @@ +{ + "ignore_php_platform_requirements": { + "8.1": true + } +} From 5b6c167bacd6fcaf410d141f632d16996f317d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Mon, 13 Sep 2021 23:57:32 +0200 Subject: [PATCH 3/6] qa: remove `laminas/laminas-zendframework-bridge` and conflict with zendframework pendant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- composer.json | 5 ++--- composer.lock | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 44e8ec5..2eb3b00 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,6 @@ }, "require": { "php": "^7.3 || ~8.0.0 || ~8.1.0", - "laminas/laminas-zendframework-bridge": "^1.0", "mezzio/mezzio-router": "^3.0", "psr/container": "^1.0", "psr/http-message": "^1.0.1", @@ -72,7 +71,7 @@ "static-analysis": "psalm --shepherd --stats", "test-coverage": "phpunit --colors=always --coverage-clover clover.xml" }, - "replace": { - "zendframework/zend-expressive-helpers": "^5.3.0" + "conflict": { + "zendframework/zend-expressive-helpers": "*" } } diff --git a/composer.lock b/composer.lock index 48da26e..477d733 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "055392157d5a0f81d52fc67f66a15695", + "content-hash": "26e035800550365b986e089126519ebd", "packages": [ { "name": "fig/http-message-util", @@ -3456,6 +3456,7 @@ "type": "github" } ], + "abandoned": true, "time": "2020-09-28T06:45:17+00:00" }, { From 761b6a5cdc882f736a1d2d42c6fba47fd595b81a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Wed, 13 Oct 2021 18:52:35 +0200 Subject: [PATCH 4/6] qa: cleanup old `expressive` fallback logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- psalm-baseline.xml | 109 ++---------------- src/ConfigProvider.php | 17 +-- src/ServerUrlMiddlewareFactory.php | 11 +- .../RouteTemplateVariableMiddleware.php | 3 - .../TemplateVariableContainerMiddleware.php | 3 - test/ServerUrlMiddlewareFactoryTest.php | 1 - .../RouteTemplateVariableMiddlewareTest.php | 39 ------- ...emplateVariableContainerMiddlewareTest.php | 12 +- test/UrlHelperMiddlewareFactoryTest.php | 1 - 9 files changed, 15 insertions(+), 181 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 709348d..cb74297 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + $parsedBody @@ -24,7 +24,7 @@ $container $routeResult - + with with @@ -81,90 +81,11 @@ $r->getValue($object) - - - $args - - - function ($args) use ($callback) { - - - $this->mockHandlerToNeverTrigger()->reveal() - - - $args[0] - - - $request - - - reveal - reveal - reveal - reveal - reveal - reveal - - assertIsArray - - - $response - $response - $response - - - getBody - getBody - getSize - getSize - hasHeader - hasHeader - hasHeader - process - process - process - reveal - reveal - reveal - will - will - will - willReturn - willReturn - willReturn - willReturn - willReturn - withHeader - - - $this->handler - $this->middleware - $this->request - $this->response - $this->stream - - - $this->handler - $this->handler - $this->handler - $this->middleware - $this->middleware - $this->middleware - $this->request - $this->request - $this->request - $this->response - $this->response - $this->response - $this->stream - $this->stream - - ExceptionInterface::class @@ -180,18 +101,6 @@ shouldDeferMissing - - array<string, Uri|string[]> - - - - array<string, Uri|string[]> - array<string, Uri|string|null[]> - array<string, Uri|string|null[]> - array<string, Uri|string|null[]> - array<string, Uri|string|null[]> - array<string, string|null[]> - andReturn with @@ -218,8 +127,8 @@ - - + + $args $container $container @@ -228,14 +137,14 @@ $container $container - + function ($args) { function ($container) use ($originalContainer) { function ($container) use ($originalContainer) { function ($container) use ($originalContainer, $routeResult) { function ($container) use ($originalContainer, $routeResult) { - + $args[1] @@ -243,7 +152,7 @@ $originalContainer $originalContainer - + get get get @@ -332,7 +241,7 @@ - + getAttribute getAttribute handle @@ -467,7 +376,7 @@ willReturn - + willReturn willReturn willReturn diff --git a/src/ConfigProvider.php b/src/ConfigProvider.php index 6904576..31821ca 100644 --- a/src/ConfigProvider.php +++ b/src/ConfigProvider.php @@ -15,20 +15,11 @@ public function __invoke(): array public function getDependencies(): array { - // @codingStandardsIgnoreStart - // phpcs:disable return [ - // Legacy Zend Framework aliases - 'aliases' => [ - \Zend\Expressive\Helper\ServerUrlHelper::class => ServerUrlHelper::class, - \Zend\Expressive\Helper\Template\TemplateVariableContainerMiddleware::class => Template\TemplateVariableContainerMiddleware::class, - \Zend\Expressive\Helper\ServerUrlMiddleware::class => ServerUrlMiddleware::class, - \Zend\Expressive\Helper\UrlHelper::class => UrlHelper::class, - \Zend\Expressive\Helper\UrlHelperMiddleware::class => UrlHelperMiddleware::class, - ], 'invokables' => [ - ServerUrlHelper::class => ServerUrlHelper::class, - Template\TemplateVariableContainerMiddleware::class => Template\TemplateVariableContainerMiddleware::class, + ServerUrlHelper::class => ServerUrlHelper::class, + Template\TemplateVariableContainerMiddleware::class + => Template\TemplateVariableContainerMiddleware::class, ], 'factories' => [ ServerUrlMiddleware::class => ServerUrlMiddlewareFactory::class, @@ -36,7 +27,5 @@ public function getDependencies(): array UrlHelperMiddleware::class => UrlHelperMiddlewareFactory::class, ], ]; - // phpcs:enable - // @codingStandardsIgnoreEnd } } diff --git a/src/ServerUrlMiddlewareFactory.php b/src/ServerUrlMiddlewareFactory.php index 0066840..80aede4 100644 --- a/src/ServerUrlMiddlewareFactory.php +++ b/src/ServerUrlMiddlewareFactory.php @@ -17,10 +17,7 @@ class ServerUrlMiddlewareFactory */ public function __invoke(ContainerInterface $container): ServerUrlMiddleware { - if ( - ! $container->has(ServerUrlHelper::class) - && ! $container->has(\zend\expressive\helper\serverurlhelper::class) - ) { + if (! $container->has(ServerUrlHelper::class)) { throw new Exception\MissingHelperException(sprintf( '%s requires a %s service at instantiation; none found', ServerUrlMiddleware::class, @@ -28,10 +25,6 @@ public function __invoke(ContainerInterface $container): ServerUrlMiddleware )); } - return new ServerUrlMiddleware( - $container->has(ServerUrlHelper::class) - ? $container->get(ServerUrlHelper::class) - : $container->get(\zend\expressive\helper\serverurlhelper::class) - ); + return new ServerUrlMiddleware($container->get(ServerUrlHelper::class)); } } diff --git a/src/Template/RouteTemplateVariableMiddleware.php b/src/Template/RouteTemplateVariableMiddleware.php index 4dd72dc..7da0bfc 100644 --- a/src/Template/RouteTemplateVariableMiddleware.php +++ b/src/Template/RouteTemplateVariableMiddleware.php @@ -41,9 +41,6 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface return $handler->handle($request->withAttribute( TemplateVariableContainer::class, $container->with('route', $routeResult) - )->withAttribute( - \Zend\Expressive\Helper\Template\TemplateVariableContainer::class, - $container->with('route', $routeResult) )); } } diff --git a/src/Template/TemplateVariableContainerMiddleware.php b/src/Template/TemplateVariableContainerMiddleware.php index a06d1a3..a521bf2 100644 --- a/src/Template/TemplateVariableContainerMiddleware.php +++ b/src/Template/TemplateVariableContainerMiddleware.php @@ -33,9 +33,6 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface return $handler->handle($request->withAttribute( TemplateVariableContainer::class, $container - )->withAttribute( - \zend\expressive\helper\template\templatevariablecontainer::class, - $container )); } } diff --git a/test/ServerUrlMiddlewareFactoryTest.php b/test/ServerUrlMiddlewareFactoryTest.php index f23bdda..a3537ae 100644 --- a/test/ServerUrlMiddlewareFactoryTest.php +++ b/test/ServerUrlMiddlewareFactoryTest.php @@ -32,7 +32,6 @@ public function testRaisesExceptionWhenContainerDoesNotContainHelper(): void { $container = $this->prophesize(ContainerInterface::class); $container->has(ServerUrlHelper::class)->willReturn(false); - $container->has(\zend\expressive\helper\serverurlhelper::class)->willReturn(false); $factory = new ServerUrlMiddlewareFactory(); diff --git a/test/Template/RouteTemplateVariableMiddlewareTest.php b/test/Template/RouteTemplateVariableMiddlewareTest.php index 4253299..984db63 100644 --- a/test/Template/RouteTemplateVariableMiddlewareTest.php +++ b/test/Template/RouteTemplateVariableMiddlewareTest.php @@ -53,19 +53,6 @@ public function testMiddlewareInjectsVariableContainerWithNullRouteIfNoVariableC ) ->will([$this->request, 'reveal']) ->shouldBeCalledTimes(1); - $this->request - ->withAttribute( - // phpcs:ignore WebimpressCodingStandard.Formatting.StringClassReference.Found - 'Zend\Expressive\Helper\Template\TemplateVariableContainer', - Argument::that(function ($container) { - TestCase::assertInstanceOf(TemplateVariableContainer::class, $container); - TestCase::assertTrue($container->has('route')); - TestCase::assertNull($container->get('route')); - return $container; - }) - ) - ->will([$this->request, 'reveal']) - ->shouldBeCalledTimes(1); $this->handler ->handle(Argument::that([$this->request, 'reveal'])) @@ -102,19 +89,6 @@ public function testMiddlewareWillInjectNullValueForRouteIfNoRouteResultInReques ) ->will([$this->request, 'reveal']) ->shouldBeCalledTimes(1); - $this->request - ->withAttribute( - // phpcs:ignore WebimpressCodingStandard.Formatting.StringClassReference.Found - 'Zend\Expressive\Helper\Template\TemplateVariableContainer', - Argument::that(function ($container) use ($originalContainer) { - TestCase::assertNotSame($container, $originalContainer); - TestCase::assertTrue($container->has('route')); - TestCase::assertNull($container->get('route')); - return $container; - }) - ) - ->will([$this->request, 'reveal']) - ->shouldBeCalledTimes(1); $this->handler ->handle(Argument::that([$this->request, 'reveal'])) @@ -153,19 +127,6 @@ public function testMiddlewareWillInjectRoutePulledFromRequestRouteResult(): voi ) ->will([$this->request, 'reveal']) ->shouldBeCalledTimes(1); - $this->request - ->withAttribute( - // phpcs:ignore WebimpressCodingStandard.Formatting.StringClassReference.Found - 'Zend\Expressive\Helper\Template\TemplateVariableContainer', - Argument::that(function ($container) use ($originalContainer, $routeResult) { - TestCase::assertNotSame($container, $originalContainer); - TestCase::assertTrue($container->has('route')); - TestCase::assertSame($container->get('route'), $routeResult->reveal()); - return $container; - }) - ) - ->will([$this->request, 'reveal']) - ->shouldBeCalledTimes(1); $this->handler ->handle(Argument::that([$this->request, 'reveal'])) diff --git a/test/Template/TemplateVariableContainerMiddlewareTest.php b/test/Template/TemplateVariableContainerMiddlewareTest.php index 6745036..d52708b 100644 --- a/test/Template/TemplateVariableContainerMiddlewareTest.php +++ b/test/Template/TemplateVariableContainerMiddlewareTest.php @@ -37,16 +37,9 @@ public function testProcessInjectsVariableContainerIntoRequestPassedToHandler(): ->withAttribute(TemplateVariableContainer::class, Argument::type(TemplateVariableContainer::class)) ->will([$this->request, 'reveal']) ->shouldBeCalledTimes(1); - $this->request - ->withAttribute( - \zend\expressive\helper\template\templatevariablecontainer::class, - Argument::type(TemplateVariableContainer::class) - ) - ->willReturn($clonedRequest) - ->shouldBeCalledTimes(1); $this->handler - ->handle($clonedRequest) + ->handle($this->request->reveal()) ->willReturn($this->response) ->shouldBeCalledTimes(1); @@ -71,9 +64,6 @@ public function testProcessIsANoOpIfVariableContainerIsAlreadyInRequest(): void $this->request ->withAttribute(TemplateVariableContainer::class, $container) ->shouldNotBeCalled(); - $this->request - ->withAttribute(\zend\expressive\helper\template\templatevariablecontainer::class, $container) - ->shouldNotBeCalled(); $this->handler ->handle(Argument::that([$this->request, 'reveal'])) diff --git a/test/UrlHelperMiddlewareFactoryTest.php b/test/UrlHelperMiddlewareFactoryTest.php index dd68ec8..636254e 100644 --- a/test/UrlHelperMiddlewareFactoryTest.php +++ b/test/UrlHelperMiddlewareFactoryTest.php @@ -47,7 +47,6 @@ public function testFactoryCreatesAndReturnsMiddlewareWhenHelperIsPresentInConta public function testFactoryRaisesExceptionWhenContainerDoesNotContainHelper(): void { $this->container->has(UrlHelper::class)->willReturn(false); - $this->container->has(\zend\expressive\helper\urlhelper::class)->willReturn(false); $factory = new UrlHelperMiddlewareFactory(); $this->expectException(MissingHelperException::class); $factory($this->container->reveal()); From 1eb48d303b9d32f1a7f279722880795c9da064dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Wed, 13 Oct 2021 18:55:43 +0200 Subject: [PATCH 5/6] qa: remove unused code while adding changed code to the baseline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I do not want to replace prophesize now and thus I'll add the single error to the baseline. Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- psalm-baseline.xml | 32 +++---------------- ...emplateVariableContainerMiddlewareTest.php | 1 - 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index cb74297..28487a4 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -17,7 +17,9 @@ - + + $container->get(ServerUrlHelper::class) + @@ -26,7 +28,6 @@ with - with @@ -133,15 +134,10 @@ $container $container $container - $container - $container - $container function ($args) { function ($container) use ($originalContainer) { - function ($container) use ($originalContainer) { - function ($container) use ($originalContainer, $routeResult) { function ($container) use ($originalContainer, $routeResult) { @@ -153,8 +149,6 @@ $originalContainer - get - get get get getAttribute @@ -168,8 +162,6 @@ handle has has - has - has process process process @@ -191,12 +183,6 @@ shouldBeCalledTimes shouldBeCalledTimes shouldBeCalledTimes - shouldBeCalledTimes - shouldBeCalledTimes - shouldBeCalledTimes - will - will - will will will will @@ -212,9 +198,6 @@ withAttribute withAttribute withAttribute - withAttribute - withAttribute - withAttribute $this->container @@ -241,7 +224,7 @@ - + getAttribute getAttribute handle @@ -252,22 +235,18 @@ reveal reveal reveal - shouldBeCalledTimes + reveal shouldBeCalledTimes shouldBeCalledTimes shouldBeCalledTimes shouldBeCalledTimes shouldBeCalledTimes shouldNotBeCalled - shouldNotBeCalled will willReturn willReturn willReturn willReturn - willReturn - withAttribute - withAttribute withAttribute withAttribute @@ -379,7 +358,6 @@ willReturn willReturn - willReturn reveal diff --git a/test/Template/TemplateVariableContainerMiddlewareTest.php b/test/Template/TemplateVariableContainerMiddlewareTest.php index d52708b..b7b001d 100644 --- a/test/Template/TemplateVariableContainerMiddlewareTest.php +++ b/test/Template/TemplateVariableContainerMiddlewareTest.php @@ -32,7 +32,6 @@ public function testProcessInjectsVariableContainerIntoRequestPassedToHandler(): ->willReturn(null) ->shouldBeCalledTimes(1); - $clonedRequest = $this->prophesize(ServerRequestInterface::class)->reveal(); $this->request ->withAttribute(TemplateVariableContainer::class, Argument::type(TemplateVariableContainer::class)) ->will([$this->request, 'reveal']) From c7dacc5c647445e6622dea9c6dcaf7bfc1f95119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Wed, 13 Oct 2021 19:00:01 +0200 Subject: [PATCH 6/6] qa: do not ignore platform requirements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- .laminas-ci.json | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .laminas-ci.json diff --git a/.laminas-ci.json b/.laminas-ci.json deleted file mode 100644 index bce3fa2..0000000 --- a/.laminas-ci.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "ignore_php_platform_requirements": { - "8.1": true - } -}