Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit97f0ce8

Browse files
bug#48483 [DependencyInjection] Remove refs that point to container.excluded services when allowed (nicolas-grekas)
This PR was merged into the 6.2 branch.Discussion----------[DependencyInjection] Remove refs that point to container.excluded services when allowed| Q | A| ------------- | ---| Branch? | 6.2| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets |Fix#48411| License | MIT| Doc PR | -Commits-------2e9fdf0 [DependencyInjection] Remove refs that point to container.excluded services when allowed
2 parents79e1d8d +2e9fdf0 commit97f0ce8

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private function processValue(mixed $value, int $rootLevel = 0, int $level = 0):
9595
$value =array_values($value);
9696
}
9797
}elseif ($valueinstanceof Reference) {
98-
if ($this->container->has($id = (string)$value)) {
98+
if ($this->container->hasDefinition($id = (string)$value) ? !$this->container->getDefinition($id)->hasTag('container.excluded') :$this->container->hasAlias($id)) {
9999
return$value;
100100
}
101101

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInvalidReferencesPassTest.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,17 @@ public function testProcessSetOnlyDecoratedAsNullOnInvalid()
165165
$this->assertEquals($unknownArgument,$decoratorDefinition->getArguments()[1]);
166166
}
167167

168+
publicfunctiontestProcessExcludedServiceAndNullOnInvalid()
169+
{
170+
$container =newContainerBuilder();
171+
$container->register('foo', \stdClass::class)->addTag('container.excluded');
172+
$container->register('bar', \stdClass::class)->addArgument(newReference('foo',$container::NULL_ON_INVALID_REFERENCE));
173+
174+
$this->process($container);
175+
176+
$this->assertSame([null],$container->getDefinition('bar')->getArguments());
177+
}
178+
168179
protectedfunctionprocess(ContainerBuilder$container)
169180
{
170181
$pass =newResolveInvalidReferencesPass();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp