Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 512812a

Browse files
committed
[DependencyInjection] Rename #[InnerService] to #[MapDecorated]
1 parent 84d35a2 commit 512812a

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

src/Symfony/Component/DependencyInjection/Attribute/InnerService.php renamed to src/Symfony/Component/DependencyInjection/Attribute/MapDecorated.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
namespace Symfony\Component\DependencyInjection\Attribute;
1313

1414
#[\Attribute(\Attribute::TARGET_PARAMETER)]
15-
class InnerService
15+
class MapDecorated
1616
{
1717
}

src/Symfony/Component/DependencyInjection/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ CHANGELOG
44
6.1
55
---
66

7+
* Add `#[MapDecorated]` attribute telling to which parameter the decorated service should be mapped in a decorator
8+
* Add `#[AsDecorator]` attribute to make a service decorates another
79
* Add `$exclude` to `TaggedIterator` and `TaggedLocator` attributes
810
* Add `$exclude` to `tagged_iterator` and `tagged_locator` configurator
911
* Add an `env` function to the expression language provider

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
1616
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
1717
use Symfony\Component\DependencyInjection\Attribute\Autowire;
18-
use Symfony\Component\DependencyInjection\Attribute\InnerService;
18+
use Symfony\Component\DependencyInjection\Attribute\MapDecorated;
1919
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
2020
use Symfony\Component\DependencyInjection\Attribute\TaggedLocator;
2121
use Symfony\Component\DependencyInjection\Attribute\Target;
@@ -273,8 +273,9 @@ private function autowireMethod(\ReflectionFunctionAbstract $reflectionMethod, a
273273
break;
274274
}
275275

276-
if (InnerService::class === $attribute->getName()) {
277-
$arguments[$index] = new Reference($this->currentId.'.inner', ContainerInterface::NULL_ON_INVALID_REFERENCE);
276+
if (MapDecorated::class === $attribute->getName()) {
277+
$definition = $this->container->getDefinition($this->currentId)
278+
$arguments[$index] = new Reference($definition->innerServiceId ?? $this->currentId.'.inner', $definition->decorationOnInvalid ?? ContainerInterface::NULL_ON_INVALID_REFERENCE);
278279

279280
break;
280281
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes_80.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Symfony\Component\DependencyInjection\Attribute\AsDecorator;
66
use Symfony\Component\DependencyInjection\Attribute\Autowire;
7-
use Symfony\Component\DependencyInjection\Attribute\InnerService;
7+
use Symfony\Component\DependencyInjection\Attribute\MapDecorated;
88
use Symfony\Component\DependencyInjection\ContainerInterface;
99
use Symfony\Contracts\Service\Attribute\Required;
1010

@@ -65,23 +65,23 @@ class AsDecoratorFoo implements AsDecoratorInterface
6565
#[AsDecorator(decorates: AsDecoratorFoo::class, priority: 10)]
6666
class AsDecoratorBar10 implements AsDecoratorInterface
6767
{
68-
public function __construct(string $arg1, #[InnerService] AsDecoratorInterface $inner)
68+
public function __construct(string $arg1, #[MapDecorated] AsDecoratorInterface $inner)
6969
{
7070
}
7171
}
7272

7373
#[AsDecorator(decorates: AsDecoratorFoo::class, priority: 20)]
7474
class AsDecoratorBar20 implements AsDecoratorInterface
7575
{
76-
public function __construct(string $arg1, #[InnerService] AsDecoratorInterface $inner)
76+
public function __construct(string $arg1, #[MapDecorated] AsDecoratorInterface $inner)
7777
{
7878
}
7979
}
8080

8181
#[AsDecorator(decorates: \NonExistent::class, onInvalid: ContainerInterface::NULL_ON_INVALID_REFERENCE)]
8282
class AsDecoratorBaz implements AsDecoratorInterface
8383
{
84-
public function __construct(#[InnerService] AsDecoratorInterface $inner = null)
84+
public function __construct(#[MapDecorated] AsDecoratorInterface $inner = null)
8585
{
8686
}
8787
}

0 commit comments

Comments
 (0)