Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eca3e37

Browse files
bug #16229 [DI] Autowiring: w/a https://bugs.php.net/62715 (nicolas-grekas)
This PR was merged into the 2.8 branch. Discussion ---------- [DI] Autowiring: w/a https://bugs.php.net/62715 | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - See https://ci.appveyor.com/project/fabpot/symfony/build/1.0.2384#L722 Commits ------- 8d49573 [DI] Autowiring: w/a https://bugs.php.net/62715
2 parents 8a76fd9 + 8d49573 commit eca3e37

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,13 @@ private function completeDefinition($id, Definition $definition)
9191
try {
9292
$value = $this->createAutowiredDefinition($typeHint, $id);
9393
} catch (RuntimeException $e) {
94-
if (!$parameter->isDefaultValueAvailable()) {
94+
if ($parameter->allowsNull()) {
95+
$value = null;
96+
} elseif ($parameter->isDefaultValueAvailable()) {
97+
$value = $parameter->getDefaultValue();
98+
} else {
9599
throw $e;
96100
}
97-
98-
$value = $parameter->getDefaultValue();
99101
}
100102
}
101103
} catch (\ReflectionException $reflectionException) {

0 commit comments

Comments
 (0)