Skip to content

Commit 0e2916a

Browse files
committed
Fix review
1 parent 3987b19 commit 0e2916a

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/Symfony/Component/DependencyInjection/Compiler/RegisterDecoratorAttributesPass.php renamed to src/Symfony/Component/DependencyInjection/Compiler/AutowireAsDecoratorPass.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
use Symfony\Component\DependencyInjection\Definition;
1717

1818
/**
19-
* Reads #[AsDecorator] attributes on definitions that are autoconfigured
19+
* Reads #[AsDecorator] attributes on definitions that are autowired
2020
* and don't have the "container.ignore_attributes" tag.
2121
*/
22-
final class RegisterDecoratorAttributesPass implements CompilerPassInterface
22+
final class AutowireAsDecoratorPass implements CompilerPassInterface
2323
{
2424
/**
2525
* {@inheritdoc}
@@ -33,12 +33,12 @@ public function process(ContainerBuilder $container)
3333
}
3434
}
3535

36-
public function accept(Definition $definition): bool
36+
private function accept(Definition $definition): bool
3737
{
38-
return !$definition->hasTag('container.ignore_attributes');
38+
return !$definition->hasTag('container.ignore_attributes') && $definition->isAutowired();
3939
}
4040

41-
public function processClass(Definition $definition, \ReflectionClass $reflectionClass)
41+
private function processClass(Definition $definition, \ReflectionClass $reflectionClass)
4242
{
4343
foreach ($reflectionClass->getAttributes(AsDecorator::class, \ReflectionAttribute::IS_INSTANCEOF) as $attribute) {
4444
$attribute = $attribute->newInstance();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ private function autowireMethod(\ReflectionFunctionAbstract $reflectionMethod, a
275275
}
276276

277277
if (Inner::class === $attribute->getName()) {
278-
$arguments[$index] = new Reference( "$class.inner", ContainerInterface::NULL_ON_INVALID_REFERENCE);
278+
$arguments[$index] = new Reference( $this->currentId.'.inner', ContainerInterface::NULL_ON_INVALID_REFERENCE);
279279

280280
break;
281281
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct()
4343
100 => [
4444
new ResolveClassPass(),
4545
new RegisterAutoconfigureAttributesPass(),
46-
new RegisterDecoratorAttributesPass(),
46+
new AutowireAsDecoratorPass(),
4747
new AttributeAutoconfigurationPass(),
4848
new ResolveInstanceofConditionalsPass(),
4949
new RegisterEnvVarProcessorsPass(),

src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Symfony\Component\DependencyInjection\Compiler\AutowirePass;
1919
use Symfony\Component\DependencyInjection\Compiler\AutowireRequiredMethodsPass;
2020
use Symfony\Component\DependencyInjection\Compiler\DecoratorServicePass;
21-
use Symfony\Component\DependencyInjection\Compiler\RegisterDecoratorAttributesPass;
21+
use Symfony\Component\DependencyInjection\Compiler\AutowireAsDecoratorPass;
2222
use Symfony\Component\DependencyInjection\Compiler\ResolveClassPass;
2323
use Symfony\Component\DependencyInjection\ContainerBuilder;
2424
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -1166,7 +1166,7 @@ public function testAutowireAttribute()
11661166
$this->assertNull($service->invalid);
11671167
}
11681168

1169-
public function testDecoratorAttribute()
1169+
public function testAsDecoratorAttribute()
11701170
{
11711171
$container = new ContainerBuilder();
11721172

@@ -1176,7 +1176,7 @@ public function testDecoratorAttribute()
11761176
$container->register(AsDecoratorBaz::class)->setAutowired(true);
11771177

11781178
(new ResolveClassPass())->process($container);
1179-
(new RegisterDecoratorAttributesPass())->process($container);
1179+
(new AutowireAsDecoratorPass())->process($container);
11801180
(new DecoratorServicePass())->process($container);
11811181
(new AutowirePass())->process($container);
11821182

0 commit comments

Comments
 (0)