diff --git a/Closure.php b/Closure.php index 671a508..f4cce16 100644 --- a/Closure.php +++ b/Closure.php @@ -76,7 +76,7 @@ protected function resolve( $arguments = []; $reflection = null; - $this->populateVariables($variables, $rtv); + $this->populateKit($variables, $rtv); if ($call instanceof \Closure) { $called = $call; $reflection = new \ReflectionMethod($call, '__invoke'); @@ -92,9 +92,9 @@ protected function resolve( if (false === $parameter->isOptional()) { throw new Exception( - 'The closured action for the rule with pattern %s needs ' . - 'a value for the parameter $%s and this value does not ' . - 'exist.', + 'The closured action for the rule with pattern %s ' . + 'needs a value for the parameter $%s and this value ' . + 'does not exist.', 1, [$rule[Router::RULE_PATTERN], $name] ); @@ -123,9 +123,9 @@ protected function resolve( if (false === $parameter->isOptional()) { throw new Exception( - 'The functional action for the rule with pattern %s needs ' . - 'a value for the parameter $%s and this value does not ' . - 'exist.', + 'The functional action for the rule with pattern %s ' . + 'needs a value for the parameter $%s and this value ' . + 'does not exist.', 3, [$rule[Router::RULE_PATTERN], $name] ); @@ -138,10 +138,16 @@ protected function resolve( } else { $return = $reflection->invokeArgs($called, $arguments); } + return $return; } - protected function populateVariables(&$variables, $rtv) + /** + * Populate Dispatcher\Kit in the variable collection + * @param array $variables Variable collection used as resolver parameters + * @param array $rtv Constructor's arguments. + */ + protected function populateKit(&$variables, $rtv) { $kitname = $this->getKitName(); if (!empty($kitname)) { diff --git a/Test/Unit/Closure.php b/Test/Unit/Closure.php index f0eb152..707af6a 100644 --- a/Test/Unit/Closure.php +++ b/Test/Unit/Closure.php @@ -60,7 +60,7 @@ function dispatchedMethodOptional($test, $foo, $bar = null) function closureDispatchedMethodWithKit() { - return function($test, $_this) { + return function ($test, $_this) { $test ->object($_this) ->isInstanceOf(__NAMESPACE__ . '\MockKit') @@ -71,7 +71,7 @@ function closureDispatchedMethodWithKit() function closureDispatchedMethod() { - return function($test, $foo, $bar) { + return function ($test, $foo, $bar) { dispatchedMethod($test, $foo, $bar); }; } @@ -240,8 +240,7 @@ protected function route(Router $router, $uri, Array $extraVariables = []) } } -if( !class_exists(__NAMESPACE__.'\MockKit') ) { - +if (!class_exists(__NAMESPACE__ . '\MockKit')) { class MockKit extends LUT\Kit { public $hasBeenConstructed = false;