diff --git a/src/Application/UI/PresenterComponentReflection.php b/src/Application/UI/PresenterComponentReflection.php index f799f1da5..9a098f943 100644 --- a/src/Application/UI/PresenterComponentReflection.php +++ b/src/Application/UI/PresenterComponentReflection.php @@ -117,15 +117,14 @@ public function hasCallableMethod($method) public static function combineArgs(\ReflectionFunctionAbstract $method, $args) { $res = []; - $i = 0; - foreach ($method->getParameters() as $param) { + foreach ($method->getParameters() as $i => $param) { $name = $param->getName(); if (!isset($args[$name]) && $param->isDefaultValueAvailable()) { - $res[$i++] = $param->getDefaultValue(); + $res[$i] = $param->getDefaultValue(); } else { - $res[$i++] = $arg = isset($args[$name]) ? $args[$name] : NULL; + $res[$i] = $arg = isset($args[$name]) ? $args[$name] : NULL; list($type, $isClass) = self::getParameterType($param); - if (!self::convertType($arg, $type, $isClass)) { + if (!self::convertType($res[$i], $type, $isClass)) { throw new BadRequestException(sprintf( 'Argument $%s passed to %s() must be %s, %s given.', $name, diff --git a/tests/UI/PresenterComponentReflection.combineArgs.phpt b/tests/UI/PresenterComponentReflection.combineArgs.phpt new file mode 100644 index 000000000..20b4db334 --- /dev/null +++ b/tests/UI/PresenterComponentReflection.combineArgs.phpt @@ -0,0 +1,24 @@ + '10', 'strParam' => 'str'])); +Assert::same([0, ''], PresenterComponentReflection::combineArgs($reflection, []));