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

Commitf3ff8aa

Browse files
committed
bug#30417 Autoconfig: don't automatically tag decorators (dunglas)
This PR was submitted for the 4.1 branch but it was merged into the 4.2 branch instead (closes#30417).Discussion----------Autoconfig: don't automatically tag decorators| Q | A| ------------- | ---| Branch? | 4.1| Bug fix? | yes| New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files -->| BC breaks? | no <!-- seehttps://symfony.com/bc -->| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tests pass? | yes <!-- please add some, will be required by reviewers -->| Fixed tickets |#30391 <!-- #-prefixed issue number(s), if any -->| License | MIT| Doc PR | n/aCommits-------05ecf82 Autoconfig: don't automatically tag decorators
2 parents7535383 +05ecf82 commitf3ff8aa

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,17 @@ private function processDefinition(ContainerBuilder $container, $id, Definition
113113
$definition->setShared($shared);
114114
}
115115

116-
$i =\count($instanceofTags);
117-
while (0 <= --$i) {
118-
foreach ($instanceofTags[$i]as$k =>$v) {
119-
foreach ($vas$v) {
120-
if ($definition->hasTag($k) &&\in_array($v,$definition->getTag($k))) {
121-
continue;
116+
// Don't add tags to service decorators
117+
if (null ===$definition->getDecoratedService()) {
118+
$i =\count($instanceofTags);
119+
while (0 <= --$i) {
120+
foreach ($instanceofTags[$i]as$k =>$v) {
121+
foreach ($vas$v) {
122+
if ($definition->hasTag($k) &&\in_array($v,$definition->getTag($k))) {
123+
continue;
124+
}
125+
$definition->addTag($k,$v);
122126
}
123-
$definition->addTag($k,$v);
124127
}
125128
}
126129
}

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,4 +307,26 @@ public function testBindingsOnInstanceofConditionals()
307307
$this->assertInstanceOf(BoundArgument::class,$bindings['$toto']);
308308
$this->assertSame(123,$bindings['$toto']->getValues()[0]);
309309
}
310+
311+
publicfunctiontestDecoratorsAreNotAutomaticallyTagged()
312+
{
313+
$container =newContainerBuilder();
314+
315+
$decorator =$container->register('decorator',self::class);
316+
$decorator->setDecoratedService('decorated');
317+
$decorator->setInstanceofConditionals([
318+
parent::class => (newChildDefinition(''))->addTag('tag'),
319+
]);
320+
$decorator->setAutoconfigured(true);
321+
$decorator->addTag('manual');
322+
323+
$container->registerForAutoconfiguration(parent::class)
324+
->addTag('tag')
325+
;
326+
327+
(newResolveInstanceofConditionalsPass())->process($container);
328+
(newResolveChildDefinitionsPass())->process($container);
329+
330+
$this->assertSame(['manual' => [[]]],$container->getDefinition('decorator')->getTags());
331+
}
310332
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp