Skip to content

Commit 72171c0

Browse files
committed
[DependencyInjection] Make DefinitionErrorExceptionPass consider IGNORE_ON_UNINITIALIZED_REFERENCE and RUNTIME_EXCEPTION_ON_INVALID_REFERENCE the same
1 parent 1fb9d17 commit 72171c0

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed
6565
}
6666

6767
if ($value instanceof Reference && $this->currentId !== $targetId = (string) $value) {
68-
if (ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE === $value->getInvalidBehavior()) {
68+
if (
69+
ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE === $value->getInvalidBehavior()
70+
|| ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $value->getInvalidBehavior()
71+
) {
6972
$this->sourceReferences[$targetId][$this->currentId] ??= true;
7073
} else {
7174
$this->sourceReferences[$targetId][$this->currentId] = false;

src/Symfony/Component/DependencyInjection/Tests/Compiler/DefinitionErrorExceptionPassTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ public function testSkipNestedErrors()
6464
$container->register('foo', 'stdClass')
6565
->addArgument(new Reference('bar', ContainerBuilder::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE));
6666

67+
$container->register('baz', 'stdClass')
68+
->addArgument(new Reference('bar', ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE));
69+
6770
$pass = new DefinitionErrorExceptionPass();
6871
$pass->process($container);
6972

0 commit comments

Comments
 (0)