From 033808da8b106ebed26a507e3bc374dcba063644 Mon Sep 17 00:00:00 2001 From: yiiliveext Date: Thu, 30 Jan 2020 10:40:19 +0200 Subject: [PATCH 1/2] Fix codestyle [skip ci] --- src/Middleware/Callback.php | 1 - src/RouteCollectorInterface.php | 1 - tests/GroupTest.php | 1 - tests/MatchingResultTest.php | 4 ++-- tests/Middleware/RouterTest.php | 6 +++--- tests/RouteTest.php | 4 ++-- 6 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Middleware/Callback.php b/src/Middleware/Callback.php index c9b9be79..aeb866ff 100644 --- a/src/Middleware/Callback.php +++ b/src/Middleware/Callback.php @@ -1,6 +1,5 @@ createRouteMiddleware(); - return new class($middleware) implements UrlMatcherInterface { + return new class ($middleware) implements UrlMatcherInterface { private $middleware; public function __construct(MiddlewareInterface $middleware) @@ -85,7 +85,7 @@ public function match(ServerRequestInterface $request): MatchingResult private function createRequestHandler(): RequestHandlerInterface { - return new class() implements RequestHandlerInterface { + return new class implements RequestHandlerInterface { public function handle(ServerRequestInterface $request): ResponseInterface { return new Response(404); @@ -95,7 +95,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface private function createRouteMiddleware(): MiddlewareInterface { - return new class() implements MiddlewareInterface { + return new class implements MiddlewareInterface { public function process( ServerRequestInterface $request, RequestHandlerInterface $handler diff --git a/tests/RouteTest.php b/tests/RouteTest.php index 553b5fdf..b6443d2f 100644 --- a/tests/RouteTest.php +++ b/tests/RouteTest.php @@ -141,7 +141,7 @@ public function testToMiddleware(): void $request = new ServerRequest('GET', '/'); $route = Route::get('/')->to( - new class() implements MiddlewareInterface { + new class implements MiddlewareInterface { public function process( ServerRequestInterface $request, RequestHandlerInterface $handler @@ -213,7 +213,7 @@ public function testBefore(): void private function getRequestHandler(): RequestHandlerInterface { - return new class() implements RequestHandlerInterface { + return new class implements RequestHandlerInterface { public function handle(ServerRequestInterface $request): ResponseInterface { return new Response(404); From 6244b7a40b7a0c8972a560f5c68bd9793c338a64 Mon Sep 17 00:00:00 2001 From: yiiliveext Date: Thu, 30 Jan 2020 10:44:47 +0200 Subject: [PATCH 2/2] Fix logical error --- src/Route.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Route.php b/src/Route.php index 4b783bc1..03e6ba1d 100644 --- a/src/Route.php +++ b/src/Route.php @@ -261,7 +261,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface $middleware = current($this->middlewares); next($this->middlewares); if ($middleware === false) { - if (!$this->nextHandler !== null) { + if ($this->nextHandler !== null) { return $this->nextHandler->handle($request); }