8000 [DependencyInjection] fixed a bug where the strict flag on references… · klend/symfony@1d362b8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1d362b8

Browse files
committed
[DependencyInjection] fixed a bug where the strict flag on references were lost (closes symfony#6607)
1 parent 1e2fb64 commit 1d362b8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private function processArguments(array $arguments, $inMethodCall = false)
8888

8989
// resolve invalid behavior
9090
if ($exists && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) {
91-
$arguments[$k] = new Reference($id);
91+
$arguments[$k] = new Reference($id, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $argument->isStrict());
9292
} elseif (!$exists && ContainerInterface::NULL_ON_INVALID_REFERENCE === $invalidBehavior) {
9393
$arguments[$k] = null;
9494
} elseif (!$exists && ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $invalidBehavior) {

tests/Symfony/Tests/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPassTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ public function testProcessRemovesPropertiesOnInvalid()
6161
$this->assertEquals(array(), $def->getProperties());
6262
}
6363

64+
public function testStrictFlagIsPreserved()
65+
{
66+
$container = new ContainerBuilder();
67+
$container->register('bar');
68+
$def = $container
69+
->register('foo')
70+
->addArgument(new Reference('bar', ContainerInterface::NULL_ON_INVALID_REFERENCE, false))
71+
;
72+
73+
$this->process($container);
74+
75+
$this->assertFalse($def->getArgument(0)->isStrict());
76+
}
77+
6478
protected function process(ContainerBuilder $container)
6579
{
6680
$pass = new ResolveInvalidReferencesPass();

0 commit comments

Comments
 (0)
0