Skip to content

Commit

Permalink
Merge pull request #17 from boesing/feature/php81
Browse files Browse the repository at this point in the history
PHP 8.1 support
  • Loading branch information
boesing authored Oct 13, 2021
2 parents f210bb7 + c7dacc5 commit 8ba1bcf
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 215 deletions.
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
}
},
"require": {
"php": "^7.3 || ~8.0.0",
"laminas/laminas-zendframework-bridge": "^1.0",
"php": "^7.3 || ~8.0.0 || ~8.1.0",
"mezzio/mezzio-router": "^3.0",
"psr/container": "^1.0",
"psr/http-message": "^1.0.1",
Expand Down Expand Up @@ -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": "*"
}
}
7 changes: 4 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

139 changes: 13 additions & 126 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.7.0@d4377c0baf3ffbf0b1ec6998e8d1be2a40971005">
<files psalm-version="4.7.2@83a0325c0a95c0ab531d6b90c877068b464377b5">
<file src="src/BodyParams/JsonStrategy.php">
<MixedAssignment occurrences="1">
<code>$parsedBody</code>
Expand All @@ -17,15 +17,16 @@
</RedundantConditionGivenDocblockType>
</file>
<file src="src/ServerUrlMiddlewareFactory.php">
<MixedArgument occurrences="1"/>
<MixedArgument occurrences="1">
<code>$container-&gt;get(ServerUrlHelper::class)</code>
</MixedArgument>
</file>
<file src="src/Template/RouteTemplateVariableMiddleware.php">
<MixedAssignment occurrences="2">
<code>$container</code>
<code>$routeResult</code>
</MixedAssignment>
<MixedMethodCall occurrences="2">
<code>with</code>
<MixedMethodCall occurrences="1">
<code>with</code>
</MixedMethodCall>
</file>
Expand Down Expand Up @@ -81,90 +82,11 @@
<code>$r-&gt;getValue($object)</code>
</MixedArgument>
</file>
<file src="test/BodyParams/BodyParamsMiddlewareTest.php">
<MissingClosureParamType occurrences="1">
<code>$args</code>
</MissingClosureParamType>
<MissingClosureReturnType occurrences="1">
<code>function ($args) use ($callback) {</code>
</MissingClosureReturnType>
<MixedArgument occurrences="6">
<code>$this-&gt;mockHandlerToNeverTrigger()-&gt;reveal()</code>
</MixedArgument>
<MixedArrayAccess occurrences="1">
<code>$args[0]</code>
</MixedArrayAccess>
<MixedAssignment occurrences="1">
<code>$request</code>
</MixedAssignment>
<PossiblyUndefinedMethod occurrences="6">
<code>reveal</code>
<code>reveal</code>
<code>reveal</code>
<code>reveal</code>
<code>reveal</code>
<code>reveal</code>
</PossiblyUndefinedMethod>
</file>
<file src="test/ConfigProviderTest.php">
<RedundantCondition occurrences="1">
<code>assertIsArray</code>
</RedundantCondition>
</file>
<file src="test/ContentLengthMiddlewareTest.php">
<MixedAssignment occurrences="3">
<code>$response</code>
<code>$response</code>
<code>$response</code>
</MixedAssignment>
<MixedMethodCall occurrences="22">
<code>getBody</code>
<code>getBody</code>
<code>getSize</code>
<code>getSize</code>
<code>hasHeader</code>
<code>hasHeader</code>
<code>hasHeader</code>
<code>process</code>
<code>process</code>
<code>process</code>
<code>reveal</code>
<code>reveal</code>
<code>reveal</code>
<code>will</code>
<code>will</code>
<code>will</code>
<code>willReturn</code>
<code>willReturn</code>
<code>willReturn</code>
<code>willReturn</code>
<code>willReturn</code>
<code>withHeader</code>
</MixedMethodCall>
<UndefinedThisPropertyAssignment occurrences="5">
<code>$this-&gt;handler</code>
<code>$this-&gt;middleware</code>
<code>$this-&gt;request</code>
<code>$this-&gt;response</code>
<code>$this-&gt;stream</code>
</UndefinedThisPropertyAssignment>
<UndefinedThisPropertyFetch occurrences="14">
<code>$this-&gt;handler</code>
<code>$this-&gt;handler</code>
<code>$this-&gt;handler</code>
<code>$this-&gt;middleware</code>
<code>$this-&gt;middleware</code>
<code>$this-&gt;middleware</code>
<code>$this-&gt;request</code>
<code>$this-&gt;request</code>
<code>$this-&gt;request</code>
<code>$this-&gt;response</code>
<code>$this-&gt;response</code>
<code>$this-&gt;response</code>
<code>$this-&gt;stream</code>
<code>$this-&gt;stream</code>
</UndefinedThisPropertyFetch>
</file>
<file src="test/ExceptionTest.php">
<InvalidLiteralArgument occurrences="1">
<code>ExceptionInterface::class</code>
Expand All @@ -180,18 +102,6 @@
<DeprecatedMethod occurrences="1">
<code>shouldDeferMissing</code>
</DeprecatedMethod>
<ImplicitToStringCast occurrences="1">
<code>array&lt;string, Uri|string[]&gt;</code>
</ImplicitToStringCast>
<InvalidReturnStatement occurrences="5"/>
<InvalidReturnType occurrences="6">
<code>array&lt;string, Uri|string[]&gt;</code>
<code>array&lt;string, Uri|string|null[]&gt;</code>
<code>array&lt;string, Uri|string|null[]&gt;</code>
<code>array&lt;string, Uri|string|null[]&gt;</code>
<code>array&lt;string, Uri|string|null[]&gt;</code>
<code>array&lt;string, string|null[]&gt;</code>
</InvalidReturnType>
<MixedMethodCall occurrences="2">
<code>andReturn</code>
<code>with</code>
Expand All @@ -218,34 +128,27 @@
</UnusedVariable>
</file>
<file src="test/Template/RouteTemplateVariableMiddlewareTest.php">
<InvalidArgument occurrences="2"/>
<MissingClosureParamType occurrences="7">
<InvalidArgument occurrences="1"/>
<MissingClosureParamType occurrences="4">
<code>$args</code>
<code>$container</code>
<code>$container</code>
<code>$container</code>
<code>$container</code>
<code>$container</code>
<code>$container</code>
</MissingClosureParamType>
<MissingClosureReturnType occurrences="5">
<MissingClosureReturnType occurrences="3">
<code>function ($args) {</code>
<code>function ($container) use ($originalContainer) {</code>
<code>function ($container) use ($originalContainer) {</code>
<code>function ($container) use ($originalContainer, $routeResult) {</code>
<code>function ($container) use ($originalContainer, $routeResult) {</code>
</MissingClosureReturnType>
<MixedArgumentTypeCoercion occurrences="4"/>
<MixedArgumentTypeCoercion occurrences="2"/>
<MixedArrayAccess occurrences="1">
<code>$args[1]</code>
</MixedArrayAccess>
<MixedAssignment occurrences="2">
<code>$originalContainer</code>
<code>$originalContainer</code>
</MixedAssignment>
<MixedMethodCall occurrences="62">
<code>get</code>
<code>get</code>
<MixedMethodCall occurrences="49">
<code>get</code>
<code>get</code>
<code>getAttribute</code>
Expand All @@ -259,8 +162,6 @@
<code>handle</code>
<code>has</code>
<code>has</code>
<code>has</code>
<code>has</code>
<code>process</code>
<code>process</code>
<code>process</code>
Expand All @@ -282,12 +183,6 @@
<code>shouldBeCalledTimes</code>
<code>shouldBeCalledTimes</code>
<code>shouldBeCalledTimes</code>
<code>shouldBeCalledTimes</code>
<code>shouldBeCalledTimes</code>
<code>shouldBeCalledTimes</code>
<code>will</code>
<code>will</code>
<code>will</code>
<code>will</code>
<code>will</code>
<code>will</code>
Expand All @@ -303,9 +198,6 @@
<code>withAttribute</code>
<code>withAttribute</code>
<code>withAttribute</code>
<code>withAttribute</code>
<code>withAttribute</code>
<code>withAttribute</code>
</MixedMethodCall>
<UndefinedThisPropertyAssignment occurrences="5">
<code>$this-&gt;container</code>
Expand All @@ -332,7 +224,7 @@
</UndefinedThisPropertyFetch>
</file>
<file src="test/Template/TemplateVariableContainerMiddlewareTest.php">
<MixedMethodCall occurrences="28">
<MixedMethodCall occurrences="24">
<code>getAttribute</code>
<code>getAttribute</code>
<code>handle</code>
Expand All @@ -343,22 +235,18 @@
<code>reveal</code>
<code>reveal</code>
<code>reveal</code>
<code>shouldBeCalledTimes</code>
<code>reveal</code>
<code>shouldBeCalledTimes</code>
<code>shouldBeCalledTimes</code>
<code>shouldBeCalledTimes</code>
<code>shouldBeCalledTimes</code>
<code>shouldBeCalledTimes</code>
<code>shouldNotBeCalled</code>
<code>shouldNotBeCalled</code>
<code>will</code>
<code>willReturn</code>
<code>willReturn</code>
<code>willReturn</code>
<code>willReturn</code>
<code>willReturn</code>
<code>withAttribute</code>
<code>withAttribute</code>
<code>withAttribute</code>
<code>withAttribute</code>
</MixedMethodCall>
Expand Down Expand Up @@ -467,8 +355,7 @@
<MixedMethodCall occurrences="1">
<code>willReturn</code>
</MixedMethodCall>
<PossiblyInvalidMethodCall occurrences="3">
<code>willReturn</code>
<PossiblyInvalidMethodCall occurrences="2">
<code>willReturn</code>
<code>willReturn</code>
</PossiblyInvalidMethodCall>
Expand Down
17 changes: 3 additions & 14 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,17 @@ 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,
UrlHelper::class => UrlHelperFactory::class,
UrlHelperMiddleware::class => UrlHelperMiddlewareFactory::class,
],
];
// phpcs:enable
// @codingStandardsIgnoreEnd
}
}
11 changes: 2 additions & 9 deletions src/ServerUrlMiddlewareFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,14 @@ 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,
ServerUrlHelper::class
));
}

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));
}
}
3 changes: 0 additions & 3 deletions src/Template/RouteTemplateVariableMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
));
}
}
3 changes: 0 additions & 3 deletions src/Template/TemplateVariableContainerMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
));
}
}
1 change: 0 additions & 1 deletion test/ServerUrlMiddlewareFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Loading

0 comments on commit 8ba1bcf

Please sign in to comment.