diff --git a/src/Router.php b/src/Router.php index 3c40e59..e3df935 100644 --- a/src/Router.php +++ b/src/Router.php @@ -217,7 +217,7 @@ public function addRoute( * * @throws \Error If the server has started. */ - public function stack(Middleware ...$middlewares): void + public function stackMiddleware(Middleware ...$middlewares): void { if ($this->running) { throw new \Error("Cannot set middlewares after the server has started"); diff --git a/test/RouterTest.php b/test/RouterTest.php index c450c5f..f7d33a2 100644 --- a/test/RouterTest.php +++ b/test/RouterTest.php @@ -125,7 +125,7 @@ public function testStack(): void return new Response(HttpStatus::OK, [], $req->getAttribute("stack")); })); - $router->stack(new class implements Middleware { + $router->stackMiddleware(new class implements Middleware { public function handleRequest(Request $request, RequestHandler $requestHandler): Response { $request->setAttribute("stack", "a"); @@ -156,7 +156,7 @@ public function testStackMultipleCalls(): void return new Response(HttpStatus::OK, [], $req->getAttribute("stack")); })); - $router->stack(new class implements Middleware { + $router->stackMiddleware(new class implements Middleware { public function handleRequest(Request $request, RequestHandler $requestHandler): Response { $request->setAttribute("stack", $request->getAttribute("stack") . "b"); @@ -164,7 +164,7 @@ public function handleRequest(Request $request, RequestHandler $requestHandler): } }); - $router->stack(new class implements Middleware { + $router->stackMiddleware(new class implements Middleware { public function handleRequest(Request $request, RequestHandler $requestHandler): Response { $request->setAttribute("stack", "a"); @@ -333,7 +333,7 @@ public function testStackAfterStart(): void $this->expectException(\Error::class); $this->expectExceptionMessage('Cannot set middlewares'); - $router->stack(new Middleware\CompressionMiddleware); + $router->stackMiddleware(new Middleware\CompressionMiddleware); } public function testSetFallbackAfterStart(): void