Skip to content

Commit a657ccb

Browse files
Add #[As-prefix] to service attributes
1 parent 09dff04 commit a657ccb

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

Attribute/TaggedItem.php renamed to Attribute/AsTaggedItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @author Nicolas Grekas <[email protected]>
1818
*/
1919
#[\Attribute(\Attribute::TARGET_CLASS)]
20-
class TaggedItem
20+
class AsTaggedItem
2121
{
2222
public function __construct(
2323
public ?string $index = null,

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CHANGELOG
77
* Add `ServicesConfigurator::remove()` in the PHP-DSL
88
* Add `%env(not:...)%` processor to negate boolean values
99
* Add support for loading autoconfiguration rules via the `#[Autoconfigure]` and `#[AutoconfigureTag]` attributes on PHP 8
10-
* Add `#[TaggedItem]` attribute for defining the index and priority of classes found in tagged iterators/locators
10+
* Add `#[AsTaggedItem]` attribute for defining the index and priority of classes found in tagged iterators/locators
1111
* Add autoconfigurable attributes
1212
* Add support for per-env configuration in loaders
1313
* Add `ContainerBuilder::willBeAvailable()` to help with conditional configuration

Compiler/PriorityTaggedServiceTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\DependencyInjection\Compiler;
1313

1414
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
15-
use Symfony\Component\DependencyInjection\Attribute\TaggedItem;
15+
use Symfony\Component\DependencyInjection\Attribute\AsTaggedItem;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
1818
use Symfony\Component\DependencyInjection\Reference;
@@ -126,7 +126,7 @@ public static function getDefault(ContainerBuilder $container, string $serviceId
126126
}
127127

128128
if ($checkTaggedItem && !$r->hasMethod($defaultMethod)) {
129-
foreach ($r->getAttributes(TaggedItem::class) as $attribute) {
129+
foreach ($r->getAttributes(AsTaggedItem::class) as $attribute) {
130130
return 'priority' === $indexAttribute ? $attribute->newInstance()->priority : $attribute->newInstance()->index;
131131
}
132132

Tests/Compiler/PriorityTaggedServiceTraitTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
16-
use Symfony\Component\DependencyInjection\Attribute\TaggedItem;
16+
use Symfony\Component\DependencyInjection\Attribute\AsTaggedItem;
1717
use Symfony\Component\DependencyInjection\ChildDefinition;
1818
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
1919
use Symfony\Component\DependencyInjection\Compiler\ResolveInstanceofConditionalsPass;
@@ -235,12 +235,12 @@ public function test($tagName, ContainerBuilder $container)
235235
}
236236
}
237237

238-
#[TaggedItem(index: 'hello', priority: 1)]
238+
#[AsTaggedItem(index: 'hello', priority: 1)]
239239
class HelloNamedService extends \stdClass
240240
{
241241
}
242242

243-
#[TaggedItem(priority: 2)]
243+
#[AsTaggedItem(priority: 2)]
244244
class HelloNamedService2
245245
{
246246
}

0 commit comments

Comments
 (0)