8000 [DI] Aliases should preserve the aliased invalid behavior by nicolas-grekas · Pull Request #20598 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DI] Aliases should preserve the aliased invalid behavior #20598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[DI] Aliases should preserve the aliased invalid behavior
  • Loading branch information
nicolas-grekas committed Nov 22, 2016
commit 7752308c962aafe24c645edff0bda2783ed6f20a
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV
}

if (!array_key_exists($id, $this->definitions) && isset($this->aliasDefinitions[$id])) {
return $this->get($this->aliasDefinitions[$id]);
return $this->get($this->aliasDefinitions[$id], $invalidBehavior);
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,18 @@ public function testSetReplacesAlias()
$this->assertSame($foo, $builder->get('alias'), '->set() replaces an existing alias');
}

public function testAliasesKeepInvalidBehavior()
{
$builder = new ContainerBuilder();

$aliased = new Definition('stdClass');
$aliased->addMethodCall('setBar', array(new Reference('bar', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)));
$builder->setDefinition('aliased', $aliased);
$builder->setAlias('alias', 'aliased');

$this->assertEquals(new \stdClass(), $builder->get('alias'));
}

public function testAddGetCompilerPass()
{
$builder = new ContainerBuilder();
Expand Down
0