diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index 3b85543b8b..c299537755 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -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) {