diff --git a/src/DI/Helpers.php b/src/DI/Helpers.php index 968d38710..c906ba7fe 100644 --- a/src/DI/Helpers.php +++ b/src/DI/Helpers.php @@ -119,7 +119,7 @@ public static function autowireArguments(\ReflectionFunctionAbstract $method, ar $optCount = 0; } - } elseif ($parameter->isOptional() || $parameter->isDefaultValueAvailable()) { + } elseif (($class && $parameter->allowsNull()) || $parameter->isOptional() || $parameter->isDefaultValueAvailable()) { // !optional + defaultAvailable = func($a = NULL, $b) since 5.4.7 // optional + !defaultAvailable = i.e. Exception::__construct, mysqli::mysqli, ... $res[$num] = $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : NULL; diff --git a/tests/DI/Helpers.autowireArguments.php71.phpt b/tests/DI/Helpers.autowireArguments.php71.phpt new file mode 100644 index 000000000..2d5eb3749 --- /dev/null +++ b/tests/DI/Helpers.autowireArguments.php71.phpt @@ -0,0 +1,42 @@ +