diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2019-08-29 09:54:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-29 09:54:45 +0200 |
commit | 130fdf50061315b377c6d8916902326d614f66b0 (patch) | |
tree | c5654118b353564b5fe2868a7317295d42443f50 | |
parent | c816dbc7f9f25eab3e7e8fe72e42b48037ad134c (diff) | |
parent | 3f12ec95f0c220dfcfa9d495f981fee6ded4b002 (diff) | |
download | nextcloud-server-130fdf50061315b377c6d8916902326d614f66b0.tar.gz nextcloud-server-130fdf50061315b377c6d8916902326d614f66b0.zip |
Merge pull request #16913 from nextcloud/fix/declare_members
SessionMiddleware: declare session property
3 files changed, 10 insertions, 30 deletions
diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index 89ebc60b226..7f416c3ed90 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -284,7 +284,6 @@ class DIContainer extends SimpleContainer implements IAppContainer { $dispatcher->registerMiddleware( new SessionMiddleware( - $c->query(IRequest::class), $c->query(IControllerMethodReflector::class), $c->query(ISession::class) ) diff --git a/lib/private/AppFramework/Middleware/SessionMiddleware.php b/lib/private/AppFramework/Middleware/SessionMiddleware.php index 7b52cc1e319..3cb60874b38 100644 --- a/lib/private/AppFramework/Middleware/SessionMiddleware.php +++ b/lib/private/AppFramework/Middleware/SessionMiddleware.php @@ -34,25 +34,14 @@ use OCP\ISession; class SessionMiddleware extends Middleware { - /** - * @var IRequest - */ - private $request; - - /** - * @var ControllerMethodReflector - */ + /** @var ControllerMethodReflector */ private $reflector; - /** - * @param IRequest $request - * @param ControllerMethodReflector $reflector - */ - public function __construct(IRequest $request, - ControllerMethodReflector $reflector, - ISession $session -) { - $this->request = $request; + /** @var ISession */ + private $session; + + public function __construct(ControllerMethodReflector $reflector, + ISession $session) { $this->reflector = $reflector; $this->session = $session; } diff --git a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php index 8d097e3a8a1..813b0d54dc6 100644 --- a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php @@ -25,20 +25,12 @@ class SessionMiddlewareTest extends \Test\TestCase { /** @var ControllerMethodReflector */ private $reflector; - /** @var Request */ - private $request; - /** @var Controller */ private $controller; protected function setUp() { parent::setUp(); - $this->request = new Request( - [], - $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), - $this->getMockBuilder(IConfig::class)->getMock() - ); $this->reflector = new ControllerMethodReflector(); $this->controller = $this->createMock(Controller::class); } @@ -50,7 +42,7 @@ class SessionMiddlewareTest extends \Test\TestCase { $session = $this->getSessionMock(0); $this->reflector->reflect($this, __FUNCTION__); - $middleware = new SessionMiddleware($this->request, $this->reflector, $session); + $middleware = new SessionMiddleware($this->reflector, $session); $middleware->beforeController($this->controller, __FUNCTION__); } @@ -61,7 +53,7 @@ class SessionMiddlewareTest extends \Test\TestCase { $session = $this->getSessionMock(1); $this->reflector->reflect($this, __FUNCTION__); - $middleware = new SessionMiddleware($this->request, $this->reflector, $session); + $middleware = new SessionMiddleware($this->reflector, $session); $middleware->afterController($this->controller, __FUNCTION__, new Response()); } @@ -69,7 +61,7 @@ class SessionMiddlewareTest extends \Test\TestCase { $session = $this->getSessionMock(1); $this->reflector->reflect($this, __FUNCTION__); - $middleware = new SessionMiddleware($this->request, $this->reflector, $session); + $middleware = new SessionMiddleware($this->reflector, $session); $middleware->beforeController($this->controller, __FUNCTION__); } @@ -77,7 +69,7 @@ class SessionMiddlewareTest extends \Test\TestCase { $session = $this->getSessionMock(0); $this->reflector->reflect($this, __FUNCTION__); - $middleware = new SessionMiddleware($this->request, $this->reflector, $session); + $middleware = new SessionMiddleware($this->reflector, $session); $middleware->afterController($this->controller, __FUNCTION__, new Response()); } |