diff --git a/src/Application/UI/Presenter.php b/src/Application/UI/Presenter.php index ab4031a58..3cabb6920 100644 --- a/src/Application/UI/Presenter.php +++ b/src/Application/UI/Presenter.php @@ -873,7 +873,7 @@ protected function createRequest($component, $destination, array $args, $mode) throw new InvalidLinkException("Unknown signal '$signal', missing handler {$reflection->getName()}::$method()"); } // convert indexed parameters to named - self::argsToParams(get_class($component), $method, $args); + self::argsToParams(get_class($component), $method, $args, array(), $mode === 'test'); } // counterpart of IStatePersistent @@ -914,12 +914,8 @@ protected function createRequest($component, $destination, array $args, $mode) if (array_key_exists(0, $args)) { throw new InvalidLinkException("Unable to pass parameters to action '$presenter:$action', missing corresponding method."); } - - } elseif ($destination === 'this') { - self::argsToParams($presenterClass, $method, $args, $this->params); - } else { - self::argsToParams($presenterClass, $method, $args); + self::argsToParams($presenterClass, $method, $args, $destination === 'this' ? $this->params : array(), $mode === 'test'); } // counterpart of IStatePersistent @@ -1003,11 +999,12 @@ protected function createRequest($component, $destination, array $args, $mode) * @param string method name * @param array arguments * @param array supplemental arguments + * @param bool prevents 'Missing parameter' exception * @return void * @throws InvalidLinkException * @internal */ - public static function argsToParams($class, $method, & $args, $supplemental = array()) + public static function argsToParams($class, $method, & $args, $supplemental = array(), $ignoreMissing = FALSE) { $i = 0; $rm = new \ReflectionMethod($class, $method); @@ -1028,7 +1025,7 @@ public static function argsToParams($class, $method, & $args, $supplemental = ar } if (!isset($args[$name])) { - if ($param->isDefaultValueAvailable() || $type === 'NULL' || $type === 'array' || $isClass) { + if ($param->isDefaultValueAvailable() || $type === 'NULL' || $type === 'array' || $isClass || $ignoreMissing) { continue; } throw new InvalidLinkException("Missing parameter \$$name required by $class::{$rm->getName()}()"); diff --git a/tests/UI/PresenterComponent.isLinkCurrent().php7.phpt b/tests/UI/PresenterComponent.isLinkCurrent().php7.phpt new file mode 100644 index 000000000..2a2c7defc --- /dev/null +++ b/tests/UI/PresenterComponent.isLinkCurrent().php7.phpt @@ -0,0 +1,43 @@ +