diff --git a/composer.json b/composer.json index b84a1c4..5a59d2d 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "ext-simplexml": "*", "filp/whoops": "^2.15", "infection/infection": "~0.25|~0.27", - "juliangut/easy-coding-standard-config": "^1.12", + "juliangut/easy-coding-standard-config": "^1.15", "juliangut/phpstan-config": "^1.1", "laminas/laminas-diactoros": "^3.2", "overtrue/phplint": "^9.0", @@ -48,7 +48,7 @@ }, "suggest": { "filp/whoops": "Enhance development error reporting (>=2.15)", - "symfony/var-dumper": "Help filp/whoops enhancing stack-traces (>=5.1)" + "symfony/var-dumper": "Help filp/whoops enhancing stack-traces (>=6.0)" }, "autoload": { "psr-4": { diff --git a/ecs.php b/ecs.php index 0b582ae..95d5a6c 100644 --- a/ecs.php +++ b/ecs.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception @@ -13,25 +13,33 @@ use SlevomatCodingStandard\Sniffs\Exceptions\ReferenceThrowableOnlySniff; use Symplify\EasyCodingStandard\Config\ECSConfig; -return static function (ECSConfig $ecsConfig): void { - $header = <<<'HEADER' +$configSet = (new ConfigSet80()) + ->setHeader(<<<'HEADER' (c) 2017-{{year}} Julián Gutiérrez @license BSD-3-Clause @link https://github.com/juliangut/slim-exception - HEADER; - - $ecsConfig->paths([ - __FILE__, - __DIR__ . '/src', - __DIR__ . '/tests', + HEADER) + ->enablePhpUnitRules() + ->setAdditionalSkips([ + ReferenceThrowableOnlySniff::class . '.ReferencedGeneralException' => [ + __DIR__ . '/src/ExceptionHandler.php', + ], ]); +$paths = [ + __FILE__, + __DIR__ . '/src', + __DIR__ . '/tests', +]; + +if (!method_exists(ECSConfig::class, 'configure')) { + return static function (ECSConfig $ecsConfig) use ($configSet, $paths): void { + $ecsConfig->paths($paths); + + $configSet->configure($ecsConfig); + }; +} - (new ConfigSet80()) - ->setHeader($header) - ->enablePhpUnitRules() - ->setAdditionalSkips([ - ReferenceThrowableOnlySniff::class . '.ReferencedGeneralException' => __DIR__ . '/src/ExceptionHandler.php', - ]) - ->configure($ecsConfig); -}; +return $configSet + ->configureBuilder() + ->withPaths($paths); diff --git a/src/ExceptionHandler.php b/src/ExceptionHandler.php index da5793b..cdf7355 100644 --- a/src/ExceptionHandler.php +++ b/src/ExceptionHandler.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception @@ -147,7 +147,7 @@ private function getFatalException(array $error): HttpException } /** - * @return array> + * @return list> */ private function getBackTrace(): array { @@ -155,10 +155,10 @@ private function getBackTrace(): array if (\function_exists('xdebug_get_function_stack')) { try { - $trace = array_map( + $trace = array_values(array_map( fn(array $frame): array => $this->normalizeFrame($frame), xdebug_get_function_stack(), - ); + )); } catch (ErrorException) { // @ignoreException } diff --git a/src/Handler/ErrorHandler.php b/src/Handler/ErrorHandler.php index 28368ea..87afbaf 100644 --- a/src/Handler/ErrorHandler.php +++ b/src/Handler/ErrorHandler.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/src/Renderer/AbstractRenderer.php b/src/Renderer/AbstractRenderer.php index 88c6407..41a5343 100644 --- a/src/Renderer/AbstractRenderer.php +++ b/src/Renderer/AbstractRenderer.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/src/Renderer/HtmlRenderer.php b/src/Renderer/HtmlRenderer.php index a714f85..f97319f 100644 --- a/src/Renderer/HtmlRenderer.php +++ b/src/Renderer/HtmlRenderer.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/src/Renderer/JsonRenderer.php b/src/Renderer/JsonRenderer.php index 49885a9..d9d6204 100644 --- a/src/Renderer/JsonRenderer.php +++ b/src/Renderer/JsonRenderer.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/src/Renderer/PlainTextRenderer.php b/src/Renderer/PlainTextRenderer.php index ff95493..862f848 100644 --- a/src/Renderer/PlainTextRenderer.php +++ b/src/Renderer/PlainTextRenderer.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/src/Renderer/XmlRenderer.php b/src/Renderer/XmlRenderer.php index 4c4f8cf..8b39411 100644 --- a/src/Renderer/XmlRenderer.php +++ b/src/Renderer/XmlRenderer.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/src/Whoops/Handler/ErrorHandler.php b/src/Whoops/Handler/ErrorHandler.php index 6a093fb..089534c 100644 --- a/src/Whoops/Handler/ErrorHandler.php +++ b/src/Whoops/Handler/ErrorHandler.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception @@ -101,8 +101,6 @@ protected function determineRenderer(): callable /** * @throws InvalidArgumentException * @throws RuntimeException - * - * @return callable(Throwable): string */ protected function determineLogRenderer(): callable { diff --git a/src/Whoops/Renderer/HtmlRenderer.php b/src/Whoops/Renderer/HtmlRenderer.php index 02380ae..6195652 100644 --- a/src/Whoops/Renderer/HtmlRenderer.php +++ b/src/Whoops/Renderer/HtmlRenderer.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/src/Whoops/Renderer/JsonRenderer.php b/src/Whoops/Renderer/JsonRenderer.php index 6bb2c5e..e187060 100644 --- a/src/Whoops/Renderer/JsonRenderer.php +++ b/src/Whoops/Renderer/JsonRenderer.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/src/Whoops/Renderer/PlainTextRenderer.php b/src/Whoops/Renderer/PlainTextRenderer.php index c615fd5..c4ce1ec 100644 --- a/src/Whoops/Renderer/PlainTextRenderer.php +++ b/src/Whoops/Renderer/PlainTextRenderer.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception @@ -65,12 +65,12 @@ private function formatError(array $error): string $error['message'], $error['file'], $error['line'], - $this->getStackTraceOutput($error['trace'] ?? []), + $this->getStackTraceOutput(array_values($error['trace'] ?? [])), ); } /** - * @param array $stackFrames + * @param list $stackFrames */ protected function getStackTraceOutput(array $stackFrames): string { diff --git a/src/Whoops/Renderer/RendererTrait.php b/src/Whoops/Renderer/RendererTrait.php index 498ec43..19dad1f 100644 --- a/src/Whoops/Renderer/RendererTrait.php +++ b/src/Whoops/Renderer/RendererTrait.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/src/Whoops/Renderer/XmlRenderer.php b/src/Whoops/Renderer/XmlRenderer.php index e5f1d05..1cf5842 100644 --- a/src/Whoops/Renderer/XmlRenderer.php +++ b/src/Whoops/Renderer/XmlRenderer.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception @@ -75,7 +75,7 @@ protected function getFormattedXml(array $data): string } /** - * @param array $data + * @param array> $data */ protected function addDataNodes(SimpleXMLElement $node, array $data, string $nodeKey): SimpleXMLElement { @@ -89,6 +89,7 @@ protected function addDataNodes(SimpleXMLElement $node, array $data, string $nod if (\is_array($value)) { /** @var SimpleXMLElement $childNode */ $childNode = $node->addChild($key); + /** @var array $value */ $this->addDataNodes($childNode, $value, $key); } else { if (\is_object($value)) { diff --git a/tests/Exception/ExceptionHandlerTest.php b/tests/Exception/ExceptionHandlerTest.php index 66690d6..355bb46 100644 --- a/tests/Exception/ExceptionHandlerTest.php +++ b/tests/Exception/ExceptionHandlerTest.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/tests/Exception/Handler/ErrorHandlerTest.php b/tests/Exception/Handler/ErrorHandlerTest.php index 67e5763..a847e6d 100644 --- a/tests/Exception/Handler/ErrorHandlerTest.php +++ b/tests/Exception/Handler/ErrorHandlerTest.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/tests/Exception/Renderer/HtmlRendererTest.php b/tests/Exception/Renderer/HtmlRendererTest.php index a4d7524..6663fbc 100644 --- a/tests/Exception/Renderer/HtmlRendererTest.php +++ b/tests/Exception/Renderer/HtmlRendererTest.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/tests/Exception/Renderer/JsonRendererTest.php b/tests/Exception/Renderer/JsonRendererTest.php index 764a334..a1c5c25 100644 --- a/tests/Exception/Renderer/JsonRendererTest.php +++ b/tests/Exception/Renderer/JsonRendererTest.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/tests/Exception/Renderer/PlainTextRendererTest.php b/tests/Exception/Renderer/PlainTextRendererTest.php index db6c036..c53b477 100644 --- a/tests/Exception/Renderer/PlainTextRendererTest.php +++ b/tests/Exception/Renderer/PlainTextRendererTest.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/tests/Exception/Renderer/XmlRendererTest.php b/tests/Exception/Renderer/XmlRendererTest.php index 37151ca..a325757 100644 --- a/tests/Exception/Renderer/XmlRendererTest.php +++ b/tests/Exception/Renderer/XmlRendererTest.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/tests/Exception/Stubs/ErrorHandlerStub.php b/tests/Exception/Stubs/ErrorHandlerStub.php index 866ec50..f8f1f25 100644 --- a/tests/Exception/Stubs/ErrorHandlerStub.php +++ b/tests/Exception/Stubs/ErrorHandlerStub.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/tests/Exception/Stubs/ExceptionHandlerStub.php b/tests/Exception/Stubs/ExceptionHandlerStub.php index e361c72..2ac8f45 100644 --- a/tests/Exception/Stubs/ExceptionHandlerStub.php +++ b/tests/Exception/Stubs/ExceptionHandlerStub.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/tests/Exception/Stubs/InspectorStub.php b/tests/Exception/Stubs/InspectorStub.php index 53156c3..f99691e 100644 --- a/tests/Exception/Stubs/InspectorStub.php +++ b/tests/Exception/Stubs/InspectorStub.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/tests/Exception/Stubs/RendererStub.php b/tests/Exception/Stubs/RendererStub.php index 81c6204..cd6e79f 100644 --- a/tests/Exception/Stubs/RendererStub.php +++ b/tests/Exception/Stubs/RendererStub.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/tests/Exception/Stubs/WhoopsErrorHandlerStub.php b/tests/Exception/Stubs/WhoopsErrorHandlerStub.php index 7e186ad..a78645e 100644 --- a/tests/Exception/Stubs/WhoopsErrorHandlerStub.php +++ b/tests/Exception/Stubs/WhoopsErrorHandlerStub.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/tests/Exception/Whoops/Handler/ErrorHandlerTest.php b/tests/Exception/Whoops/Handler/ErrorHandlerTest.php index 02e2fc0..2e491b8 100644 --- a/tests/Exception/Whoops/Handler/ErrorHandlerTest.php +++ b/tests/Exception/Whoops/Handler/ErrorHandlerTest.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/tests/Exception/Whoops/Renderer/HtmlRendererTest.php b/tests/Exception/Whoops/Renderer/HtmlRendererTest.php index d81d2c8..95a8177 100644 --- a/tests/Exception/Whoops/Renderer/HtmlRendererTest.php +++ b/tests/Exception/Whoops/Renderer/HtmlRendererTest.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/tests/Exception/Whoops/Renderer/JsonRendererTest.php b/tests/Exception/Whoops/Renderer/JsonRendererTest.php index 349e438..3b37345 100644 --- a/tests/Exception/Whoops/Renderer/JsonRendererTest.php +++ b/tests/Exception/Whoops/Renderer/JsonRendererTest.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception @@ -72,7 +72,7 @@ public function testNotPrettifiedOutput(): void $output = ob_get_clean(); $expected = '{"error":[{' - . '"type":"Slim\\\\Exception\\\\HttpForbiddenException",' + . '"type":"Slim\\\Exception\\\HttpForbiddenException",' . '"message":"403 Forbidden",' . '"code":403,' . '"file":"' . __FILE__ . '",' @@ -133,7 +133,7 @@ public function testNotPrettifiedNoTraceOutput(): void $output = ob_get_clean(); $expected = '{"error":[{' - . '"type":"Slim\\\\Exception\\\\HttpForbiddenException",' + . '"type":"Slim\\\Exception\\\HttpForbiddenException",' . '"message":"403 Forbidden",' . '"code":403,' . '"file":"' . __FILE__ . '",' diff --git a/tests/Exception/Whoops/Renderer/PlainTextRendererTest.php b/tests/Exception/Whoops/Renderer/PlainTextRendererTest.php index 4ac1ea3..7083b4f 100644 --- a/tests/Exception/Whoops/Renderer/PlainTextRendererTest.php +++ b/tests/Exception/Whoops/Renderer/PlainTextRendererTest.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception diff --git a/tests/Exception/Whoops/Renderer/XmlRendererTest.php b/tests/Exception/Whoops/Renderer/XmlRendererTest.php index d455c52..3e6751c 100644 --- a/tests/Exception/Whoops/Renderer/XmlRendererTest.php +++ b/tests/Exception/Whoops/Renderer/XmlRendererTest.php @@ -1,7 +1,7 @@ + * (c) 2017-2024 Julián Gutiérrez * * @license BSD-3-Clause * @link https://github.com/juliangut/slim-exception