[DependencyInjection] fixed a bug where the strict flag on references were lost (closes #6607)
This commit is contained in:
parent
1e2fb64817
commit
1d362b8849
@ -88,7 +88,7 @@ class ResolveInvalidReferencesPass implements CompilerPassInterface
|
||||
|
||||
// resolve invalid behavior
|
||||
if ($exists && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) {
|
||||
$arguments[$k] = new Reference($id);
|
||||
$arguments[$k] = new Reference($id, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $argument->isStrict());
|
||||
} elseif (!$exists && ContainerInterface::NULL_ON_INVALID_REFERENCE === $invalidBehavior) {
|
||||
$arguments[$k] = null;
|
||||
} elseif (!$exists && ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $invalidBehavior) {
|
||||
|
@ -61,6 +61,20 @@ class ResolveInvalidReferencesPassTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(array(), $def->getProperties());
|
||||
}
|
||||
|
||||
public function testStrictFlagIsPreserved()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('bar');
|
||||
$def = $container
|
||||
->register('foo')
|
||||
->addArgument(new Reference('bar', ContainerInterface::NULL_ON_INVALID_REFERENCE, false))
|
||||
;
|
||||
|
||||
$this->process($container);
|
||||
|
||||
$this->assertFalse($def->getArgument(0)->isStrict());
|
||||
}
|
||||
|
||||
protected function process(ContainerBuilder $container)
|
||||
{
|
||||
$pass = new ResolveInvalidReferencesPass();
|
||||
|
Reference in New Issue
Block a user