diff --git a/Slim/App.php b/Slim/App.php index d3e27b062..e6d31b237 100644 --- a/Slim/App.php +++ b/Slim/App.php @@ -47,9 +47,7 @@ class App { use CallableResolverAwareTrait; - use MiddlewareAwareTrait { - add as addMiddleware; - } + use MiddlewareAwareTrait; /** * Current version diff --git a/Slim/MiddlewareAwareTrait.php b/Slim/MiddlewareAwareTrait.php index 6d504c04e..ce49c96c6 100644 --- a/Slim/MiddlewareAwareTrait.php +++ b/Slim/MiddlewareAwareTrait.php @@ -53,7 +53,7 @@ trait MiddlewareAwareTrait * @throws RuntimeException If middleware is added while the stack is dequeuing * @throws UnexpectedValueException If the middleware doesn't return an instance of \Psr\Http\Message\ResponseInterface */ - public function add(callable $callable) + protected function addMiddleware(callable $callable) { if ($this->middlewareLock) { throw new RuntimeException('Middleware can’t be added once the stack is dequeuing'); diff --git a/Slim/Route.php b/Slim/Route.php index 5ae40ac66..9b03a0f56 100644 --- a/Slim/Route.php +++ b/Slim/Route.php @@ -22,9 +22,7 @@ */ class Route extends Routable implements RouteInterface { - use MiddlewareAwareTrait { - add as addMiddleware; - } + use MiddlewareAwareTrait; /** * HTTP methods supported by this route diff --git a/tests/Mocks/Stackable.php b/tests/Mocks/Stackable.php index c9b798e20..3d92850c9 100644 --- a/tests/Mocks/Stackable.php +++ b/tests/Mocks/Stackable.php @@ -33,4 +33,10 @@ public function testMiddlewareKernel(ServerRequestInterface $req, ResponseInterf { return $res->write('hello from testMiddlewareKernel'); } + + public function add($callable) + { + $this->addMiddleware($callable); + return $this; + } }