Skip to content

Commit

Permalink
Rename stack to stackMiddleware
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Aug 5, 2023
1 parent bf0e378 commit c5179df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
8 changes: 4 additions & 4 deletions test/RouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -156,15 +156,15 @@ 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");
return $requestHandler->handleRequest($request);
}
});

$router->stack(new class implements Middleware {
$router->stackMiddleware(new class implements Middleware {
public function handleRequest(Request $request, RequestHandler $requestHandler): Response
{
$request->setAttribute("stack", "a");
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c5179df

Please sign in to comment.