This commit is contained in:
Nicolas Grekas 2015-10-13 18:59:07 +02:00
parent 8a76fd9dbc
commit 8d49573fb6
1 changed files with 5 additions and 3 deletions

View File

@ -91,11 +91,13 @@ class AutowirePass implements CompilerPassInterface
try {
$value = $this->createAutowiredDefinition($typeHint, $id);
} catch (RuntimeException $e) {
if (!$parameter->isDefaultValueAvailable()) {
if ($parameter->allowsNull()) {
$value = null;
} elseif ($parameter->isDefaultValueAvailable()) {
$value = $parameter->getDefaultValue();
} else {
throw $e;
}
$value = $parameter->getDefaultValue();
}
}
} catch (\ReflectionException $reflectionException) {