Skip to content

Commit ff708cb

Browse files
Add #[As-prefix] to service attributes
1 parent 36b7381 commit ff708cb

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

Attribute/EventListener.php renamed to Attribute/AsEventListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @author Alexander M. Turek <[email protected]>
1818
*/
1919
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
20-
class EventListener
20+
class AsEventListener
2121
{
2222
public function __construct(
2323
public ?string $event = null,

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CHANGELOG
44
5.3
55
---
66

7-
* Add `EventListener` attribute for declaring listeners on PHP 8
7+
* Add `#[AsEventListener]` attribute for declaring listeners on PHP 8
88

99
5.1.0
1010
-----

Tests/DependencyInjection/RegisterListenersPassTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Symfony\Component\DependencyInjection\ContainerBuilder;
2020
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
2121
use Symfony\Component\DependencyInjection\Reference;
22-
use Symfony\Component\EventDispatcher\Attribute\EventListener;
22+
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
2323
use Symfony\Component\EventDispatcher\DependencyInjection\AddEventAliasesPass;
2424
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
2525
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -248,7 +248,7 @@ public function testTaggedInvokableEventListener()
248248
}
249249

250250
$container = new ContainerBuilder();
251-
$container->registerAttributeForAutoconfiguration(EventListener::class, static function (ChildDefinition $definition, EventListener $attribute): void {
251+
$container->registerAttributeForAutoconfiguration(AsEventListener::class, static function (ChildDefinition $definition, AsEventListener $attribute): void {
252252
$definition->addTag('kernel.event_listener', get_object_vars($attribute));
253253
});
254254
$container->register('foo', TaggedInvokableListener::class)->setAutoconfigured(true);
@@ -282,7 +282,7 @@ public function testTaggedMultiEventListener()
282282
}
283283

284284
$container = new ContainerBuilder();
285-
$container->registerAttributeForAutoconfiguration(EventListener::class, static function (ChildDefinition $definition, EventListener $attribute): void {
285+
$container->registerAttributeForAutoconfiguration(AsEventListener::class, static function (ChildDefinition $definition, AsEventListener $attribute): void {
286286
$definition->addTag('kernel.event_listener', get_object_vars($attribute));
287287
});
288288
$container->register('foo', TaggedMultiListener::class)->setAutoconfigured(true);

Tests/Fixtures/TaggedInvokableListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
namespace Symfony\Component\EventDispatcher\Tests\Fixtures;
1313

14-
use Symfony\Component\EventDispatcher\Attribute\EventListener;
14+
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
1515

16-
#[EventListener]
16+
#[AsEventListener]
1717
final class TaggedInvokableListener
1818
{
1919
public function __invoke(CustomEvent $event): void

Tests/Fixtures/TaggedMultiListener.php

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

1212
namespace Symfony\Component\EventDispatcher\Tests\Fixtures;
1313

14-
use Symfony\Component\EventDispatcher\Attribute\EventListener;
14+
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
1515

16-
#[EventListener(event: CustomEvent::class, method: 'onCustomEvent')]
17-
#[EventListener(event: 'foo', priority: 42)]
18-
#[EventListener(event: 'bar', method: 'onBarEvent')]
16+
#[AsEventListener(event: CustomEvent::class, method: 'onCustomEvent')]
17+
#[AsEventListener(event: 'foo', priority: 42)]
18+
#[AsEventListener(event: 'bar', method: 'onBarEvent')]
1919
final class TaggedMultiListener
2020
{
2121
public function onCustomEvent(CustomEvent $event): void

0 commit comments

Comments
 (0)