From 371425f3c5dc8584ecff1d7cc52f90032c2b9acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20L=C3=BCcke?= Date: Wed, 15 Dec 2021 19:47:41 +0100 Subject: [PATCH 1/2] Bugfix: PHPStan kommt damit nicht klar --- api/tests/unit/Middleware/ErrorHandlerTest.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/api/tests/unit/Middleware/ErrorHandlerTest.php b/api/tests/unit/Middleware/ErrorHandlerTest.php index 1c4e9d5..a6b7253 100644 --- a/api/tests/unit/Middleware/ErrorHandlerTest.php +++ b/api/tests/unit/Middleware/ErrorHandlerTest.php @@ -46,13 +46,17 @@ class ErrorHandlerTest extends Unit ]); /** @noinspection PhpFieldAssignmentTypeMismatchInspection */ $this->request = $this->makeEmpty(ServerRequestInterface::class, [ - 'getAttribute' => function($name) { - return match ($name) { - RouteContext::ROUTE_PARSER => $this->makeEmpty(RouteParserInterface::class), - RouteContext::ROUTING_RESULTS => $this->makeEmpty(RoutingResults::class), - default => null, - }; - } + 'getAttribute' => function ($name) { + /** @noinspection PhpSwitchCanBeReplacedWithMatchExpressionInspection */ + switch ($name) { + case RouteContext::ROUTE_PARSER: + return $this->makeEmpty(RouteParserInterface::class); + case RouteContext::ROUTING_RESULTS: + return $this->makeEmpty(RoutingResults::class); + default: + return null; + } + }, ]); } From aae4764f5e34cbe1689f0eee3b9330cd2b94ff8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20L=C3=BCcke?= Date: Wed, 15 Dec 2021 19:48:20 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Refactor:=20Probleme=20f=C3=BCr=20PHP-Storm?= =?UTF-8?q?=20beseitigen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/tests/unit/Middleware/ErrorHandlerTest.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/api/tests/unit/Middleware/ErrorHandlerTest.php b/api/tests/unit/Middleware/ErrorHandlerTest.php index a6b7253..036fd8b 100644 --- a/api/tests/unit/Middleware/ErrorHandlerTest.php +++ b/api/tests/unit/Middleware/ErrorHandlerTest.php @@ -31,7 +31,6 @@ class ErrorHandlerTest extends Unit protected function _before(): void { parent::_before(); - /** @noinspection PhpFieldAssignmentTypeMismatchInspection */ $this->app = $this->makeEmpty(App::class, [ 'getResponseFactory' => $this->makeEmpty(ResponseFactoryInterface::class, [ 'createResponse' => $this->makeEmpty(ResponseInterface::class, [ @@ -44,7 +43,6 @@ class ErrorHandlerTest extends Unit ]), ]), ]); - /** @noinspection PhpFieldAssignmentTypeMismatchInspection */ $this->request = $this->makeEmpty(ServerRequestInterface::class, [ 'getAttribute' => function ($name) { /** @noinspection PhpSwitchCanBeReplacedWithMatchExpressionInspection */ @@ -65,13 +63,11 @@ class ErrorHandlerTest extends Unit */ public function testUseWithLogger(): void { - /** @noinspection PhpFieldAssignmentTypeMismatchInspection */ $this->exception = $this->make(Exception::class, [ 'message' => '', 'code' => 400, 'file' => '/path(to/file', ]); - /** @noinspection PhpFieldAssignmentTypeMismatchInspection */ $this->logger = $this->makeEmpty(LoggerInterface::class, [ 'error' => Expected::once(), ]); @@ -85,14 +81,12 @@ class ErrorHandlerTest extends Unit */ public function testUseWithHttpException(): void { - /** @noinspection PhpFieldAssignmentTypeMismatchInspection */ $this->exception = $this->make(HttpException::class, [ - 'message' => '', - 'code' => 400, - 'file' => '/path(to/file', - 'getTitle' => Expected::once('The Title'), + 'message' => '', + 'code' => 400, + 'file' => '/path(to/file', + 'getTitle' => Expected::once('The Title'), ]); - /** @noinspection PhpFieldAssignmentTypeMismatchInspection */ $this->logger = $this->makeEmpty(LoggerInterface::class, []); $middleWare = new ErrorHandler($this->app); @@ -105,13 +99,11 @@ class ErrorHandlerTest extends Unit */ public function testUseWithGeneralException(): void { - /** @noinspection PhpFieldAssignmentTypeMismatchInspection */ $this->exception = $this->make(Exception::class, [ 'message' => '', 'code' => 400, 'file' => '/path(to/file', ]); - /** @noinspection PhpFieldAssignmentTypeMismatchInspection */ $this->logger = $this->makeEmpty(LoggerInterface::class, []); $middleWare = new ErrorHandler($this->app);