Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump PSR-7 dependency to allow usage with v2 #42

Merged
merged 3 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,17 @@
"php": "~8.0.0 || ~8.1.0 || ~8.2.0",
"fig/http-message-util": "^1.1",
"laminas/laminas-escaper": "^2.10.0",
"psr/http-message": "^1.0",
"psr/http-server-middleware": "^1.0"
"psr/http-message": "^1.0 || ^2.0",
"psr/http-server-middleware": "^1.0.2"
},
"require-dev": {
"laminas/laminas-coding-standard": "~2.5.0",
"laminas/laminas-diactoros": "^2.22",
"laminas/laminas-diactoros": "^2.25 || ^3.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say lets drop support for http-message v1.0 and bump it to 1.1, then we can just require diactoros v3 and don't have to hassle with v2 here.

WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main reason to keep 1.0 support was because I'm not 100% certain which of our components depend explicitly on Diactoros, and this would allow usage with v2 or v3 of that library until those are updated.

I think in 3.11 we could drop 1.0 support.

"phpunit/phpunit": "^9.5.26",
"psalm/plugin-phpunit": "^0.18.3",
"vimeo/psalm": "^5.0.0"
},
"conflict": {
"laminas/laminas-diactoros": "<1.7.1",
"zendframework/zend-stratigility": "*"
},
"suggest": {
Expand Down
316 changes: 153 additions & 163 deletions composer.lock

Large diffs are not rendered by default.

131 changes: 67 additions & 64 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,154 +1,163 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.0.0@4e177bf0c9f03c17d2fbfd83b7cc9c47605274d8">
<files psalm-version="5.11.0@c9b192ab8400fdaf04b2b13d110575adc879aa90">
<file src="src/Handler/NotFoundHandler.php">
<MixedInferredReturnType occurrences="1">
<MixedInferredReturnType>
<code>ResponseInterface</code>
</MixedInferredReturnType>
<MixedMethodCall occurrences="1">
<MixedMethodCall>
<code>withStatus</code>
</MixedMethodCall>
<MixedReturnStatement occurrences="1">
<MixedReturnStatement>
<code>$responseFactory()</code>
</MixedReturnStatement>
</file>
<file src="src/Middleware/DoublePassMiddlewareDecorator.php">
<MissingClosureParamType occurrences="2">
<MissingClosureParamType>
<code>$request</code>
<code>$response</code>
</MissingClosureParamType>
<MixedArgument occurrences="1">
<MixedArgument>
<code>$request</code>
</MixedArgument>
<UnusedClosureParam occurrences="1">
<UnusedClosureParam>
<code>$response</code>
</UnusedClosureParam>
</file>
<file src="src/Middleware/ErrorHandler.php">
<MixedArgument occurrences="1">
<MixedArgument>
<code>$response</code>
</MixedArgument>
<MixedArgumentTypeCoercion occurrences="1">
<code>$this-&gt;createErrorHandler()</code>
<MixedArgumentTypeCoercion>
<code><![CDATA[$this->createErrorHandler()]]></code>
</MixedArgumentTypeCoercion>
<MixedAssignment occurrences="1">
<MixedAssignment>
<code>$response</code>
</MixedAssignment>
<MixedInferredReturnType occurrences="1">
<MixedInferredReturnType>
<code>ResponseInterface</code>
</MixedInferredReturnType>
<MixedReturnStatement occurrences="1">
<MixedReturnStatement>
<code>$responseFactory()</code>
</MixedReturnStatement>
</file>
<file src="src/Middleware/ErrorResponseGenerator.php">
<UnusedParam>
<code>$request</code>
</UnusedParam>
</file>
<file src="src/Middleware/HostMiddlewareDecorator.php">
<PossiblyUnusedReturnValue>
<code>ResponseInterface</code>
</PossiblyUnusedReturnValue>
</file>
<file src="src/Next.php">
<MixedAssignment occurrences="1">
<MixedAssignment>
<code>$middleware</code>
</MixedAssignment>
<MixedInferredReturnType occurrences="1">
<MixedInferredReturnType>
<code>ResponseInterface</code>
</MixedInferredReturnType>
<MixedMethodCall occurrences="1">
<MixedMethodCall>
<code>process</code>
</MixedMethodCall>
<MixedReturnStatement occurrences="1">
<code>$middleware-&gt;process($request, $next)</code>
<MixedReturnStatement>
<code><![CDATA[$middleware->process($request, $next)]]></code>
</MixedReturnStatement>
</file>
<file src="src/functions/double-pass-middleware.legacy.php">
<InvalidReturnStatement occurrences="1">
<InvalidReturnStatement>
<code>laminas_doublePassMiddleware(...func_get_args())</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<InvalidReturnType>
<code>Middleware\DoublePassMiddlewareDecorator</code>
</InvalidReturnType>
<MixedArgument occurrences="2">
<MixedArgument>
<code>func_get_args()</code>
<code>func_get_args()</code>
</MixedArgument>
<UndefinedClass occurrences="1">
<UndefinedClass>
<code>Middleware\DoublePassMiddlewareDecorator</code>
</UndefinedClass>
</file>
<file src="src/functions/host.legacy.php">
<InvalidReturnStatement occurrences="1">
<InvalidReturnStatement>
<code>laminas_host(...func_get_args())</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<InvalidReturnType>
<code>Middleware\HostMiddlewareDecorator</code>
</InvalidReturnType>
<MixedArgument occurrences="2">
<MixedArgument>
<code>func_get_args()</code>
<code>func_get_args()</code>
</MixedArgument>
<UndefinedClass occurrences="1">
<UndefinedClass>
<code>Middleware\HostMiddlewareDecorator</code>
</UndefinedClass>
</file>
<file src="src/functions/middleware.legacy.php">
<InvalidReturnStatement occurrences="1">
<InvalidReturnStatement>
<code>laminas_middleware(...func_get_args())</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<InvalidReturnType>
<code>Middleware\CallableMiddlewareDecorator</code>
</InvalidReturnType>
<MixedArgument occurrences="1">
<MixedArgument>
<code>func_get_args()</code>
</MixedArgument>
<UndefinedClass occurrences="1">
<UndefinedClass>
<code>Middleware\CallableMiddlewareDecorator</code>
</UndefinedClass>
</file>
<file src="src/functions/path.legacy.php">
<InvalidReturnStatement occurrences="1">
<InvalidReturnStatement>
<code>laminas_path(...func_get_args())</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<InvalidReturnType>
<code>Middleware\PathMiddlewareDecorator</code>
</InvalidReturnType>
<MixedArgument occurrences="2">
<MixedArgument>
<code>func_get_args()</code>
<code>func_get_args()</code>
</MixedArgument>
<UndefinedClass occurrences="1">
<UndefinedClass>
<code>Middleware\PathMiddlewareDecorator</code>
</UndefinedClass>
</file>
<file src="test/Exception/ExceptionTest.php">
<MixedInferredReturnType occurrences="1">
<MixedInferredReturnType>
<code>Generator</code>
</MixedInferredReturnType>
<PossiblyFalseOperand occurrences="1">
<PossiblyFalseOperand>
<code>strrpos(ExceptionInterface::class, '\\')</code>
</PossiblyFalseOperand>
</file>
<file src="test/Middleware/CallableMiddlewareDecoratorTest.php">
<MissingClosureParamType occurrences="2">
<MissingClosureParamType>
<code>$handler</code>
<code>$request</code>
</MissingClosureParamType>
<UnusedClosureParam occurrences="2">
<UnusedClosureParam>
<code>$handler</code>
<code>$request</code>
</UnusedClosureParam>
</file>
<file src="test/Middleware/DoublePassMiddlewareDecoratorExceptionTest.php">
<MissingClosureParamType occurrences="2">
<MissingClosureParamType>
<code>$next</code>
<code>$request</code>
</MissingClosureParamType>
<MixedArgument occurrences="1">
<MixedArgument>
<code>$autoloader</code>
</MixedArgument>
<MixedAssignment occurrences="1">
<MixedAssignment>
<code>$autoloader</code>
</MixedAssignment>
<UnusedClosureParam occurrences="2">
<UnusedClosureParam>
<code>$next</code>
<code>$request</code>
</UnusedClosureParam>
</file>
<file src="test/Middleware/DoublePassMiddlewareDecoratorTest.php">
<MissingClosureParamType occurrences="10">
<MissingClosureParamType>
<code>$next</code>
<code>$next</code>
<code>$next</code>
Expand All @@ -160,83 +169,77 @@
<code>$response</code>
<code>$response</code>
</MissingClosureParamType>
<UnusedClosureParam occurrences="10">
<UnusedClosureParam>
<code>$next</code>
<code>$next</code>
<code>$next</code>
<code>$next</code>
<code>$request</code>
<code>$request</code>
<code>$request</code>
<code>$request</code>
<code>$response</code>
<code>$response</code>
</UnusedClosureParam>
</file>
<file src="test/Middleware/ErrorHandlerTest.php">
<MixedArgument occurrences="1">
<MixedArgument>
<code>$listeners</code>
</MixedArgument>
<MixedAssignment occurrences="1">
<MixedAssignment>
<code>$listeners</code>
</MixedAssignment>
<UnusedClosureParam occurrences="2">
<code>$e</code>
<code>$request</code>
</UnusedClosureParam>
</file>
<file src="test/Middleware/HostMiddlewareDecoratorTest.php">
<MixedInferredReturnType occurrences="1">
<MixedInferredReturnType>
<code>Generator</code>
</MixedInferredReturnType>
</file>
<file src="test/Middleware/NotFoundHandlerTest.php">
<DeprecatedClass occurrences="1">
<DeprecatedClass>
<code>new NotFoundHandler($responseFactory)</code>
</DeprecatedClass>
</file>
<file src="test/Middleware/PathMiddlewareDecoratorIntegrationTest.php">
<MixedAssignment occurrences="1">
<MixedAssignment>
<code>$receivedUri</code>
</MixedAssignment>
<MixedMethodCall occurrences="4">
<MixedMethodCall>
<code>getPath</code>
<code>getPath</code>
<code>getUri</code>
<code>getUri</code>
</MixedMethodCall>
<MixedOperand occurrences="1">
<MixedOperand>
<code>$path</code>
</MixedOperand>
</file>
<file src="test/Middleware/PathMiddlewareDecoratorTest.php">
<MixedMethodCall occurrences="2">
<MixedMethodCall>
<code>getPath</code>
<code>getUri</code>
</MixedMethodCall>
<ParamNameMismatch occurrences="1">
<ParamNameMismatch>
<code>$req</code>
</ParamNameMismatch>
</file>
<file src="test/MiddlewarePipeTest.php">
<ParamNameMismatch occurrences="2">
<ParamNameMismatch>
<code>$req</code>
<code>$req</code>
</ParamNameMismatch>
</file>
<file src="test/NextTest.php">
<ParamNameMismatch occurrences="2">
<ParamNameMismatch>
<code>$req</code>
<code>$req</code>
</ParamNameMismatch>
</file>
<file src="test/TestAsset/DelegatingMiddleware.php">
<ParamNameMismatch occurrences="1">
<ParamNameMismatch>
<code>$req</code>
</ParamNameMismatch>
</file>
<file src="test/TestAsset/ShortCircuitingMiddleware.php">
<ParamNameMismatch occurrences="1">
<ParamNameMismatch>
<code>$req</code>
</ParamNameMismatch>
</file>
Expand Down
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedBaselineEntry="true"
findUnusedCode="true"
errorBaseline="psalm-baseline.xml"
>
<projectFiles>
Expand Down
13 changes: 10 additions & 3 deletions test/Handler/NotFoundHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace LaminasTest\Stratigility\Handler;

use Laminas\Diactoros\Uri;
use Laminas\Stratigility\Handler\NotFoundHandler;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand All @@ -14,13 +16,15 @@ class NotFoundHandlerTest extends TestCase
{
public function testReturnsResponseWith404StatusAndErrorMessageInBody(): void
{
/** @var StreamInterface&MockObject $stream */
$stream = $this->createMock(StreamInterface::class);
$stream
->expects(self::once())
->method('write')
->with('Cannot POST https://example.com/foo')
->willReturnSelf();
->with('Cannot POST https://example.org/foo')
->willReturn(0);

/** @var ResponseInterface&MockObject $response */
$response = $this->createMock(ResponseInterface::class);
$response
->expects(self::once())
Expand All @@ -32,15 +36,18 @@ public function testReturnsResponseWith404StatusAndErrorMessageInBody(): void
->method('getBody')
->willReturn($stream);

/** @var ServerRequestInterface&MockObject $request */
$request = $this->createMock(ServerRequestInterface::class);
$request
->expects(self::once())
->method('getMethod')
->willReturn('POST');

$uri = new Uri('https://example.org/foo');
$request
->expects(self::once())
->method('getUri')
->willReturn('https://example.com/foo');
->willReturn($uri);

$responseFactory = static fn(): ResponseInterface => $response;

Expand Down
1 change: 0 additions & 1 deletion test/Middleware/CallableMiddlewareDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public function testMiddlewareFunction(): void
$toDecorate = static fn(): string => 'foo';

$middleware = middleware($toDecorate);
self::assertInstanceOf(CallableMiddlewareDecorator::class, $middleware);
self::assertEquals(new CallableMiddlewareDecorator($toDecorate), $middleware);
}
}
Loading