Skip to content

Commit e18d991

Browse files
feature #40556 Add #[As-prefix] to service attributes (nicolas-grekas)
This PR was merged into the 5.3-dev branch. Discussion ---------- Add `#[As-prefix]` to service attributes | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - This PR renames all existing attributes with the `As` prefix, as I proposed several times already. This should help autocompletion, and it's required to not collide with existing class names (eg the `Command` class, but also the old `Controller` class, etc.) I think this `As` prefix is a convention for the better. Commits ------- 4f1318963a Add `#[As-prefix]` to service attributes
2 parents 1b3431a + 88bea98 commit e18d991

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
use Symfony\Component\DependencyInjection\Parameter;
6060
use Symfony\Component\DependencyInjection\Reference;
6161
use Symfony\Component\DependencyInjection\ServiceLocator;
62-
use Symfony\Component\EventDispatcher\Attribute\EventListener;
62+
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
6363
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
6464
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
6565
use Symfony\Component\Finder\Finder;
@@ -556,7 +556,7 @@ public function load(array $configs, ContainerBuilder $container)
556556
$container->registerForAutoconfiguration(LoggerAwareInterface::class)
557557
->addMethodCall('setLogger', [new Reference('logger')]);
558558

559-
$container->registerAttributeForAutoconfiguration(EventListener::class, static function (ChildDefinition $definition, EventListener $attribute): void {
559+
$container->registerAttributeForAutoconfiguration(AsEventListener::class, static function (ChildDefinition $definition, AsEventListener $attribute): void {
560560
$definition->addTag('kernel.event_listener', get_object_vars($attribute));
561561
});
562562
$container->registerAttributeForAutoconfiguration(AsController::class, static function (ChildDefinition $definition, AsController $attribute): void {

0 commit comments

Comments
 (0)