From a5d6ac394ab2dc02cfcbbbbd75049b31f91f0104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Wed, 26 Feb 2020 22:39:42 +0100 Subject: [PATCH 01/10] Require PHP 7.4 --- .scrutinizer.yml | 2 +- .travis.yml | 4 +--- composer.json | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index d754df6..a01d1bd 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -6,7 +6,7 @@ build: rabbitmq: false mongodb: false php: - version: 7.3 + version: 7.4 cache: disabled: false diff --git a/.travis.yml b/.travis.yml index cf7f671..efc25fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,7 @@ sudo: false language: php php: - - 7.3 - - 7.4snapshot + - 7.4 - nightly cache: @@ -22,7 +21,6 @@ script: jobs: allow_failures: - - php: 7.4snapshot - php: nightly include: diff --git a/composer.json b/composer.json index 1162b97..3a589db 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "keywords": ["PSR-15", "RFC-7807", "error handling"], "require": { - "php": "^7.3", + "php": "^7.4", "ext-json": "^1.7", "fig/http-message-util": "^1.1", "lcobucci/content-negotiation-middleware": "^2.0", From effec49118fccc3e0680e95d1dca5412bae5ffb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Wed, 26 Feb 2020 22:40:03 +0100 Subject: [PATCH 02/10] Allow installation on PHP 8.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3a589db..6db94c6 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "keywords": ["PSR-15", "RFC-7807", "error handling"], "require": { - "php": "^7.4", + "php": "^7.4 || ^8.0", "ext-json": "^1.7", "fig/http-message-util": "^1.1", "lcobucci/content-negotiation-middleware": "^2.0", From 82d5e1b3f7cad2f99eff3b377ed47b8ad7f8aa35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Wed, 26 Feb 2020 22:40:33 +0100 Subject: [PATCH 03/10] Let extension version be handled by PHP version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6db94c6..eb8a36e 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "keywords": ["PSR-15", "RFC-7807", "error handling"], "require": { "php": "^7.4 || ^8.0", - "ext-json": "^1.7", + "ext-json": "*", "fig/http-message-util": "^1.1", "lcobucci/content-negotiation-middleware": "^2.0", "psr/http-factory": "^1.0", From a0259a0dfd4f0bd073c8abae63b9f65bdbc1090c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Wed, 26 Feb 2020 22:44:08 +0100 Subject: [PATCH 04/10] Upgrade lcobucci/content-negotiation-middleware to v2.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index eb8a36e..aac8bec 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "php": "^7.4 || ^8.0", "ext-json": "*", "fig/http-message-util": "^1.1", - "lcobucci/content-negotiation-middleware": "^2.0", + "lcobucci/content-negotiation-middleware": "^2.2", "psr/http-factory": "^1.0", "psr/http-server-middleware": "^1.0", "psr/log": "^1.1" From 9d97db572867afdfab0f5b6163cdf0694aa0283d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Wed, 26 Feb 2020 22:45:22 +0100 Subject: [PATCH 05/10] Replace zendframework/zend-diactoros with laminas/laminas-diactoros --- composer.json | 4 ++-- tests/ErrorConversionMiddlewareTest.php | 6 +++--- tests/ErrorLoggingMiddlewareTest.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index aac8bec..2ae6e0e 100644 --- a/composer.json +++ b/composer.json @@ -21,14 +21,14 @@ }, "require-dev": { "infection/infection": "^0.13", + "laminas/laminas-diactoros": "^2.2", "lcobucci/coding-standard": "^3.0", "phpstan/phpstan": "^0.11", "phpstan/phpstan-deprecation-rules": "^0.11", "phpstan/phpstan-phpunit": "^0.11", "phpstan/phpstan-strict-rules": "^0.11", "phpunit/phpunit": "^8.2", - "squizlabs/php_codesniffer": "^3.4", - "zendframework/zend-diactoros": "^2.0" + "squizlabs/php_codesniffer": "^3.4" }, "autoload": { "psr-4": { diff --git a/tests/ErrorConversionMiddlewareTest.php b/tests/ErrorConversionMiddlewareTest.php index 0ebf151..a3445db 100644 --- a/tests/ErrorConversionMiddlewareTest.php +++ b/tests/ErrorConversionMiddlewareTest.php @@ -4,6 +4,9 @@ namespace Lcobucci\ErrorHandling\Tests; use Fig\Http\Message\StatusCodeInterface; +use Laminas\Diactoros\Response; +use Laminas\Diactoros\ResponseFactory; +use Laminas\Diactoros\ServerRequest; use Lcobucci\ContentNegotiation\UnformattedResponse; use Lcobucci\ErrorHandling\DebugInfoStrategy; use Lcobucci\ErrorHandling\DebugInfoStrategy\NoDebugInfo; @@ -16,9 +19,6 @@ use Psr\Http\Server\RequestHandlerInterface; use RuntimeException; use Throwable; -use Zend\Diactoros\Response; -use Zend\Diactoros\ResponseFactory; -use Zend\Diactoros\ServerRequest; /** * @coversDefaultClass \Lcobucci\ErrorHandling\ErrorConversionMiddleware diff --git a/tests/ErrorLoggingMiddlewareTest.php b/tests/ErrorLoggingMiddlewareTest.php index 0a189f3..6a63adf 100644 --- a/tests/ErrorLoggingMiddlewareTest.php +++ b/tests/ErrorLoggingMiddlewareTest.php @@ -3,14 +3,14 @@ namespace Lcobucci\ErrorHandling\Tests; +use Laminas\Diactoros\Response; +use Laminas\Diactoros\ServerRequest; use Lcobucci\ErrorHandling\ErrorLoggingMiddleware; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Http\Server\RequestHandlerInterface; use Psr\Log\LoggerInterface; use RuntimeException; -use Zend\Diactoros\Response; -use Zend\Diactoros\ServerRequest; /** * @coversDefaultClass \Lcobucci\ErrorHandling\ErrorLoggingMiddleware From 087d56fd35fb0b1a1f53a9a04c38e66ebb47c206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Wed, 26 Feb 2020 22:51:27 +0100 Subject: [PATCH 06/10] Upgrade PHPStan to v0.12 --- composer.json | 8 ++++---- src/DebugInfoStrategy/NoTrace.php | 3 +++ src/StatusCodeExtractionStrategy/ClassMap.php | 4 +++- tests/ErrorConversionMiddlewareTest.php | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 2ae6e0e..b5def7c 100644 --- a/composer.json +++ b/composer.json @@ -23,10 +23,10 @@ "infection/infection": "^0.13", "laminas/laminas-diactoros": "^2.2", "lcobucci/coding-standard": "^3.0", - "phpstan/phpstan": "^0.11", - "phpstan/phpstan-deprecation-rules": "^0.11", - "phpstan/phpstan-phpunit": "^0.11", - "phpstan/phpstan-strict-rules": "^0.11", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-deprecation-rules": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", + "phpstan/phpstan-strict-rules": "^0.12", "phpunit/phpunit": "^8.2", "squizlabs/php_codesniffer": "^3.4" }, diff --git a/src/DebugInfoStrategy/NoTrace.php b/src/DebugInfoStrategy/NoTrace.php index ebf464c..09dab90 100644 --- a/src/DebugInfoStrategy/NoTrace.php +++ b/src/DebugInfoStrategy/NoTrace.php @@ -26,6 +26,9 @@ public function extractDebugInfo(Throwable $error): ?array return $debugInfo; } + /** + * @return Generator> + */ private function streamStack(?Throwable $previous): Generator { if ($previous === null) { diff --git a/src/StatusCodeExtractionStrategy/ClassMap.php b/src/StatusCodeExtractionStrategy/ClassMap.php index b750fa6..e21b0f3 100644 --- a/src/StatusCodeExtractionStrategy/ClassMap.php +++ b/src/StatusCodeExtractionStrategy/ClassMap.php @@ -42,6 +42,8 @@ public function extractStatusCode(Throwable $error): int } } - return $error->getCode() ?: StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR; + $code = $error->getCode(); + + return $code !== 0 ? $code : StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR; } } diff --git a/tests/ErrorConversionMiddlewareTest.php b/tests/ErrorConversionMiddlewareTest.php index a3445db..519bac1 100644 --- a/tests/ErrorConversionMiddlewareTest.php +++ b/tests/ErrorConversionMiddlewareTest.php @@ -94,7 +94,7 @@ public function processShouldConvertTheExceptionIntoAnUnformattedResponseWithThe } /** - * @return array>> + * @return array>> */ public function possibleConversions(): iterable { From 52ee0d4ef6eb700ae71efd855ffc0a4bc106f1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Wed, 26 Feb 2020 22:52:21 +0100 Subject: [PATCH 07/10] Use PHPStan extension installer --- composer.json | 1 + phpstan.neon.dist | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/composer.json b/composer.json index b5def7c..1f8fba7 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "infection/infection": "^0.13", "laminas/laminas-diactoros": "^2.2", "lcobucci/coding-standard": "^3.0", + "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^0.12", "phpstan/phpstan-deprecation-rules": "^0.12", "phpstan/phpstan-phpunit": "^0.12", diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 46705ff..7c87780 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,9 +1,3 @@ -includes: - - vendor/phpstan/phpstan-phpunit/extension.neon - - vendor/phpstan/phpstan-phpunit/rules.neon - - vendor/phpstan/phpstan-deprecation-rules/rules.neon - - vendor/phpstan/phpstan-strict-rules/rules.neon - parameters: level: 7 paths: From 49af5f2a6fd7fe4ea992e382f51e52d87b031a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Wed, 26 Feb 2020 22:54:21 +0100 Subject: [PATCH 08/10] Upgrade coding-standard --- composer.json | 4 ++-- src/ErrorConversionMiddleware.php | 17 +++-------------- src/ErrorLoggingMiddleware.php | 5 +---- src/StatusCodeExtractionStrategy/ClassMap.php | 2 +- tests/ErrorConversionMiddlewareTest.php | 11 ++--------- tests/ErrorLoggingMiddlewareTest.php | 2 +- 6 files changed, 10 insertions(+), 31 deletions(-) diff --git a/composer.json b/composer.json index 1f8fba7..7fff023 100644 --- a/composer.json +++ b/composer.json @@ -22,14 +22,14 @@ "require-dev": { "infection/infection": "^0.13", "laminas/laminas-diactoros": "^2.2", - "lcobucci/coding-standard": "^3.0", + "lcobucci/coding-standard": "^4.0", "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^0.12", "phpstan/phpstan-deprecation-rules": "^0.12", "phpstan/phpstan-phpunit": "^0.12", "phpstan/phpstan-strict-rules": "^0.12", "phpunit/phpunit": "^8.2", - "squizlabs/php_codesniffer": "^3.4" + "squizlabs/php_codesniffer": "^3.5" }, "autoload": { "psr-4": { diff --git a/src/ErrorConversionMiddleware.php b/src/ErrorConversionMiddleware.php index 461416e..78af67e 100644 --- a/src/ErrorConversionMiddleware.php +++ b/src/ErrorConversionMiddleware.php @@ -24,20 +24,9 @@ final class ErrorConversionMiddleware implements MiddlewareInterface private const STATUS_URL = 'https://httpstatuses.com/'; - /** - * @var ResponseFactoryInterface - */ - private $responseFactory; - - /** - * @var DebugInfoStrategy - */ - private $debugInfoStrategy; - - /** - * @var StatusCodeExtractionStrategy - */ - private $statusCodeExtractor; + private ResponseFactoryInterface $responseFactory; + private DebugInfoStrategy $debugInfoStrategy; + private StatusCodeExtractionStrategy $statusCodeExtractor; public function __construct( ResponseFactoryInterface $responseFactory, diff --git a/src/ErrorLoggingMiddleware.php b/src/ErrorLoggingMiddleware.php index c710794..1c9002f 100644 --- a/src/ErrorLoggingMiddleware.php +++ b/src/ErrorLoggingMiddleware.php @@ -12,10 +12,7 @@ final class ErrorLoggingMiddleware implements MiddlewareInterface { - /** - * @var LoggerInterface - */ - private $logger; + private LoggerInterface $logger; public function __construct(LoggerInterface $logger) { diff --git a/src/StatusCodeExtractionStrategy/ClassMap.php b/src/StatusCodeExtractionStrategy/ClassMap.php index e21b0f3..a5108d7 100644 --- a/src/StatusCodeExtractionStrategy/ClassMap.php +++ b/src/StatusCodeExtractionStrategy/ClassMap.php @@ -24,7 +24,7 @@ final class ClassMap implements StatusCodeExtractionStrategy /** * @var array */ - private $conversionMap; + private array $conversionMap; /** * @param array $conversionMap diff --git a/tests/ErrorConversionMiddlewareTest.php b/tests/ErrorConversionMiddlewareTest.php index 519bac1..d0ca5bf 100644 --- a/tests/ErrorConversionMiddlewareTest.php +++ b/tests/ErrorConversionMiddlewareTest.php @@ -29,15 +29,8 @@ */ final class ErrorConversionMiddlewareTest extends TestCase { - /** - * @var ResponseFactory - */ - private $responseFactory; - - /** - * @var ClassMap - */ - private $statusCodeExtractor; + private ResponseFactory $responseFactory; + private ClassMap $statusCodeExtractor; /** * @before diff --git a/tests/ErrorLoggingMiddlewareTest.php b/tests/ErrorLoggingMiddlewareTest.php index 6a63adf..febd446 100644 --- a/tests/ErrorLoggingMiddlewareTest.php +++ b/tests/ErrorLoggingMiddlewareTest.php @@ -20,7 +20,7 @@ final class ErrorLoggingMiddlewareTest extends TestCase /** * @var LoggerInterface&MockObject */ - private $logger; + private LoggerInterface $logger; /** * @before From f89f4f54bb0102035894103340f1b78cf90ccc10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Wed, 26 Feb 2020 22:55:28 +0100 Subject: [PATCH 09/10] Upgrade Infection to v0.15 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7fff023..54fdc82 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "psr/log": "^1.1" }, "require-dev": { - "infection/infection": "^0.13", + "infection/infection": "^0.15", "laminas/laminas-diactoros": "^2.2", "lcobucci/coding-standard": "^4.0", "phpstan/extension-installer": "^1.0", From 29f71b06f50eb0b522151a5a4738a53bd54f589c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Wed, 26 Feb 2020 22:56:03 +0100 Subject: [PATCH 10/10] Upgrade PHPUnit to v9.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 54fdc82..a34efe4 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "phpstan/phpstan-deprecation-rules": "^0.12", "phpstan/phpstan-phpunit": "^0.12", "phpstan/phpstan-strict-rules": "^0.12", - "phpunit/phpunit": "^8.2", + "phpunit/phpunit": "^9.0", "squizlabs/php_codesniffer": "^3.5" }, "autoload": {