From 8d253cc752a587c9e6dee70ae736776cf37be201 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 22 Oct 2015 18:32:44 +0100 Subject: [PATCH 1/2] Change visibility on the add method to protected --- Slim/MiddlewareAwareTrait.php | 2 +- tests/Mocks/Stackable.php | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Slim/MiddlewareAwareTrait.php b/Slim/MiddlewareAwareTrait.php index 6d504c04e..767e01b90 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 add(callable $callable) { if ($this->middlewareLock) { throw new RuntimeException('Middleware can’t be added once the stack is dequeuing'); diff --git a/tests/Mocks/Stackable.php b/tests/Mocks/Stackable.php index c9b798e20..0fb8ed7a2 100644 --- a/tests/Mocks/Stackable.php +++ b/tests/Mocks/Stackable.php @@ -17,7 +17,9 @@ */ class Stackable { - use MiddlewareAwareTrait; + use MiddlewareAwareTrait { + add as addMiddleware; + } public function __invoke(ServerRequestInterface $req, ResponseInterface $res) { @@ -33,4 +35,10 @@ public function testMiddlewareKernel(ServerRequestInterface $req, ResponseInterf { return $res->write('hello from testMiddlewareKernel'); } + + public function add($callable) + { + $this->addMiddleware($callable); + return $this; + } } From 45bbb8f60ccf15701b9f3290df4ba4b80318179e Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 28 Oct 2015 23:27:32 +0000 Subject: [PATCH 2/2] Change method name to addMiddleware and remove aliasing --- Slim/App.php | 4 +--- Slim/MiddlewareAwareTrait.php | 2 +- Slim/Route.php | 4 +--- tests/Mocks/Stackable.php | 4 +--- 4 files changed, 4 insertions(+), 10 deletions(-) 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 767e01b90..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 */ - protected 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 0fb8ed7a2..3d92850c9 100644 --- a/tests/Mocks/Stackable.php +++ b/tests/Mocks/Stackable.php @@ -17,9 +17,7 @@ */ class Stackable { - use MiddlewareAwareTrait { - add as addMiddleware; - } + use MiddlewareAwareTrait; public function __invoke(ServerRequestInterface $req, ResponseInterface $res) {