Permalink
Browse files

Middlewares must not pass their params by reference, to preserver Res…

…ponse / Request immutability
  • Loading branch information...
1 parent 1ec0ad7 commit 44620ba06f62618549aef27ab1b77f03002ae67f @cdujeu cdujeu committed May 12, 2016
@@ -127,7 +127,7 @@ public static function parseRestParameters(ServerRequestInterface &$request){
* @return ResponseInterface
* @throws AuthRequiredException
*/
- public static function registryActionMiddleware(ServerRequestInterface &$request, ResponseInterface &$response, callable $nextCallable = null){
+ public static function registryActionMiddleware(ServerRequestInterface $request, ResponseInterface $response, callable $nextCallable = null){
$action = null;
if(ConfService::currentContextIsRestAPI()){
$action = Controller::parseRestParameters($request);
@@ -41,7 +41,7 @@ class AuthCliMiddleware
* @return ResponseInterface
* @throws AuthRequiredException
*/
- public static function handleRequest(ServerRequestInterface &$requestInterface, ResponseInterface &$responseInterface, callable $next = null){
+ public static function handleRequest(ServerRequestInterface $requestInterface, ResponseInterface $responseInterface, callable $next = null){
$options = $requestInterface->getAttribute("cli-options");
@@ -40,7 +40,7 @@ class CliMiddleware
* @param callable|null $next
* @throws WorkspaceNotFoundException
*/
- public static function handleRequest(ServerRequestInterface &$requestInterface, ResponseInterface &$responseInterface, callable $next = null){
+ public static function handleRequest(ServerRequestInterface $requestInterface, ResponseInterface $responseInterface, callable $next = null){
/**
* @var OutputInterface
@@ -33,7 +33,7 @@
class SapiMiddleware
{
- public static function handleRequest(ServerRequestInterface &$request, ResponseInterface &$response, callable $next = null){
+ public static function handleRequest(ServerRequestInterface $request, ResponseInterface $response, callable $next = null){
$params = $request->getQueryParams();
$postParams = $request->getParsedBody();
@@ -41,7 +41,7 @@ class SecureTokenMiddleware
* @param callable|null $next
* @throws PydioException
*/
- public static function handleRequest(\Psr\Http\Message\ServerRequestInterface &$requestInterface, \Psr\Http\Message\ResponseInterface &$responseInterface, callable $next = null){
+ public static function handleRequest(\Psr\Http\Message\ServerRequestInterface $requestInterface, \Psr\Http\Message\ResponseInterface $responseInterface, callable $next = null){
$pluginsUnSecureActions = ConfService::getDeclaredUnsecureActions();
$pluginsUnSecureActions[] = "get_secure_token";
@@ -29,7 +29,7 @@
class SessionMiddleware
{
- public static function handleRequest(\Psr\Http\Message\ServerRequestInterface &$requestInterface, \Psr\Http\Message\ResponseInterface &$responseInterface, callable $next = null){
+ public static function handleRequest(\Psr\Http\Message\ServerRequestInterface $requestInterface, \Psr\Http\Message\ResponseInterface $responseInterface, callable $next = null){
$getParams = $requestInterface->getQueryParams();
$sessionName = SessionService::getSessionName();
@@ -95,7 +95,7 @@ protected function nextCallable(&$request, &$response){
if($this->middleWares->valid()){
$callable = $this->middleWares->current();
$this->middleWares->next();
- $response = call_user_func_array($callable, array(&$request, &$response, function($req, $res){
+ $response = call_user_func_array($callable, array($request, $response, function($req, $res){
return $this->nextCallable($req, $res);
}));
}
@@ -111,9 +111,9 @@ protected function nextCallable(&$request, &$response){
* @param callable|null $next
* @return ResponseInterface
*/
- public static function callNextMiddleWare(ServerRequestInterface &$requestInterface, ResponseInterface &$responseInterface, callable $next = null){
+ public static function callNextMiddleWare(ServerRequestInterface $requestInterface, ResponseInterface $responseInterface, callable $next = null){
if($next !== null){
- $responseInterface = call_user_func_array($next, array(&$requestInterface, &$responseInterface));
+ $responseInterface = call_user_func_array($next, array($requestInterface, $responseInterface));
}
return $responseInterface;
}
@@ -125,9 +125,9 @@ public static function callNextMiddleWare(ServerRequestInterface &$requestInterf
* @param callable|null $next
* @return ResponseInterface
*/
- public static function callNextMiddleWareAndRewind(callable $comparisonFunction, ServerRequestInterface &$requestInterface, ResponseInterface &$responseInterface, callable $next = null){
+ public static function callNextMiddleWareAndRewind(callable $comparisonFunction, ServerRequestInterface $requestInterface, ResponseInterface $responseInterface, callable $next = null){
if($next !== null){
- $responseInterface = call_user_func_array($next, array(&$requestInterface, &$responseInterface));
+ $responseInterface = call_user_func_array($next, array($requestInterface, $responseInterface));
}
self::$middleWareInstance->rewind();
while(!$comparisonFunction(self::$middleWareInstance->current())){

0 comments on commit 44620ba

Please sign in to comment.