From 8d49573fb63d9af7a3cb73d8a11b90116cc42f86 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 13 Oct 2015 18:59:07 +0200 Subject: [PATCH] [DI] Autowiring: w/a https://bugs.php.net/62715 --- .../DependencyInjection/Compiler/AutowirePass.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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) {