diff --git a/packages/asynchronous-bundle/src/Attribute/AsyncCommandHandler.php b/packages/asynchronous-bundle/src/Attribute/AsyncCommandHandler.php new file mode 100644 index 00000000..2093215f --- /dev/null +++ b/packages/asynchronous-bundle/src/Attribute/AsyncCommandHandler.php @@ -0,0 +1,20 @@ +handles = $handles; + $this->method = $method; + } +} diff --git a/packages/asynchronous-bundle/src/Attribute/AsyncEventListener.php b/packages/asynchronous-bundle/src/Attribute/AsyncEventListener.php new file mode 100644 index 00000000..fb9198b7 --- /dev/null +++ b/packages/asynchronous-bundle/src/Attribute/AsyncEventListener.php @@ -0,0 +1,20 @@ +subscribesTo = $subscribesTo; + $this->method = $method; + } +} diff --git a/packages/asynchronous-bundle/src/SimpleBusAsynchronousBundle.php b/packages/asynchronous-bundle/src/SimpleBusAsynchronousBundle.php index 06deeac8..df26595b 100644 --- a/packages/asynchronous-bundle/src/SimpleBusAsynchronousBundle.php +++ b/packages/asynchronous-bundle/src/SimpleBusAsynchronousBundle.php @@ -2,12 +2,17 @@ namespace SimpleBus\AsynchronousBundle; +use Reflector; +use SimpleBus\AsynchronousBundle\Attribute\AsyncCommandHandler; +use SimpleBus\AsynchronousBundle\Attribute\AsyncEventListener; use SimpleBus\AsynchronousBundle\DependencyInjection\Compiler\CollectAsynchronousEventNames; use SimpleBus\AsynchronousBundle\DependencyInjection\SimpleBusAsynchronousExtension; +use SimpleBus\SymfonyBridge\DependencyInjection\AttributeTagResolver; use SimpleBus\SymfonyBridge\DependencyInjection\Compiler\AutoRegister; use SimpleBus\SymfonyBridge\DependencyInjection\Compiler\ConfigureMiddlewares; use SimpleBus\SymfonyBridge\DependencyInjection\Compiler\RegisterHandlers; use SimpleBus\SymfonyBridge\DependencyInjection\Compiler\RegisterSubscribers; +use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -21,6 +26,24 @@ public function getContainerExtension(): SimpleBusAsynchronousExtension public function build(ContainerBuilder $container): void { + $container->registerAttributeForAutoconfiguration( + AsyncCommandHandler::class, + static function (ChildDefinition $definition, AsyncCommandHandler $attribute, Reflector $reflector): void { + foreach (AttributeTagResolver::resolveTags($reflector, $attribute->handles, $attribute->method, 'handles') as $tag) { + $definition->addTag('asynchronous_command_handler', $tag); + } + } + ); + + $container->registerAttributeForAutoconfiguration( + AsyncEventListener::class, + static function (ChildDefinition $definition, AsyncEventListener $attribute, Reflector $reflector): void { + foreach (AttributeTagResolver::resolveTags($reflector, $attribute->subscribesTo, $attribute->method, 'subscribes_to') as $tag) { + $definition->addTag('asynchronous_event_subscriber', $tag); + } + } + ); + $container->addCompilerPass( new ConfigureMiddlewares('simple_bus.asynchronous.command_bus', 'asynchronous_command_bus_middleware') ); diff --git a/packages/asynchronous-bundle/tests/Functional/Attribute/AttrAsyncCommand.php b/packages/asynchronous-bundle/tests/Functional/Attribute/AttrAsyncCommand.php new file mode 100644 index 00000000..b35b5849 --- /dev/null +++ b/packages/asynchronous-bundle/tests/Functional/Attribute/AttrAsyncCommand.php @@ -0,0 +1,5 @@ +spy->handled[] = $command; + } +} diff --git a/packages/asynchronous-bundle/tests/Functional/Attribute/AttributeAsyncEventSubscriber.php b/packages/asynchronous-bundle/tests/Functional/Attribute/AttributeAsyncEventSubscriber.php new file mode 100644 index 00000000..f4292083 --- /dev/null +++ b/packages/asynchronous-bundle/tests/Functional/Attribute/AttributeAsyncEventSubscriber.php @@ -0,0 +1,17 @@ +spy->handled[] = $event; + } +} diff --git a/packages/asynchronous-bundle/tests/Functional/Attribute/AttributeUnionAsyncCommandHandler.php b/packages/asynchronous-bundle/tests/Functional/Attribute/AttributeUnionAsyncCommandHandler.php new file mode 100644 index 00000000..25af29de --- /dev/null +++ b/packages/asynchronous-bundle/tests/Functional/Attribute/AttributeUnionAsyncCommandHandler.php @@ -0,0 +1,17 @@ +spy->handled[] = $command; + } +} diff --git a/packages/asynchronous-bundle/tests/Functional/Attribute/AttributeUnionAsyncCommandHandlerExplicit.php b/packages/asynchronous-bundle/tests/Functional/Attribute/AttributeUnionAsyncCommandHandlerExplicit.php new file mode 100644 index 00000000..9f8d4bd2 --- /dev/null +++ b/packages/asynchronous-bundle/tests/Functional/Attribute/AttributeUnionAsyncCommandHandlerExplicit.php @@ -0,0 +1,17 @@ +spy->handled[] = $command; + } +} diff --git a/packages/asynchronous-bundle/tests/Functional/Attribute/AttributeUnionAsyncCommandHandlerProcess.php b/packages/asynchronous-bundle/tests/Functional/Attribute/AttributeUnionAsyncCommandHandlerProcess.php new file mode 100644 index 00000000..6f4f3321 --- /dev/null +++ b/packages/asynchronous-bundle/tests/Functional/Attribute/AttributeUnionAsyncCommandHandlerProcess.php @@ -0,0 +1,17 @@ +spy->handled[] = $command; + } +} diff --git a/packages/asynchronous-bundle/tests/Functional/SimpleBusAsynchronousBundleTest.php b/packages/asynchronous-bundle/tests/Functional/SimpleBusAsynchronousBundleTest.php index 12a2fac2..20e9e25b 100644 --- a/packages/asynchronous-bundle/tests/Functional/SimpleBusAsynchronousBundleTest.php +++ b/packages/asynchronous-bundle/tests/Functional/SimpleBusAsynchronousBundleTest.php @@ -3,6 +3,14 @@ namespace SimpleBus\AsynchronousBundle\Tests\Functional; use PHPUnit\Framework\Attributes\Test; +use SimpleBus\AsynchronousBundle\Tests\Functional\Attribute\AttrAsyncCommand; +use SimpleBus\AsynchronousBundle\Tests\Functional\Attribute\AttrAsyncCommandA; +use SimpleBus\AsynchronousBundle\Tests\Functional\Attribute\AttrAsyncCommandB; +use SimpleBus\AsynchronousBundle\Tests\Functional\Attribute\AttrAsyncCommandC; +use SimpleBus\AsynchronousBundle\Tests\Functional\Attribute\AttrAsyncCommandD; +use SimpleBus\AsynchronousBundle\Tests\Functional\Attribute\AttrAsyncCommandE; +use SimpleBus\AsynchronousBundle\Tests\Functional\Attribute\AttrAsyncCommandF; +use SimpleBus\AsynchronousBundle\Tests\Functional\Attribute\AttrEvent; use SimpleBus\Message\Bus\MessageBus; use SimpleBus\Serialization\Envelope\DefaultEnvelope; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; @@ -37,6 +45,121 @@ public function itNotifiesSynchronousEventSubscribersAndPublishesEvents(): void $this->assertSame([$event], $eventPublisher->publishedMessages()); } + #[Test] + public function itNotifiesAsynchronousEventSubscribersUsingAttributes(): void + { + $kernel = static::createKernel(); + $kernel->boot(); + + $event = new AttrEvent(); + + /** @var MessageBus $asynchronousEventBus */ + $asynchronousEventBus = $kernel->getContainer()->get('asynchronous_event_bus'); + $asynchronousEventBus->handle($event); + + /** @var Spy $spy */ + $spy = $kernel->getContainer()->get('spy'); + $this->assertSame([$event], $spy->handled); + + /** @var PublisherSpy $eventPublisher */ + $eventPublisher = $kernel->getContainer()->get('event_publisher_spy'); + $this->assertSame([], $eventPublisher->publishedMessages()); + } + + #[Test] + public function itHandlesAsynchronousCommandsUsingAttributes(): void + { + $kernel = static::createKernel(); + $kernel->boot(); + + $command = new AttrAsyncCommand(); + + /** @var MessageBus $asynchronousCommandBus */ + $asynchronousCommandBus = $kernel->getContainer()->get('asynchronous_command_bus'); + $asynchronousCommandBus->handle($command); + + /** @var PublisherSpy $commandPublisher */ + $commandPublisher = $kernel->getContainer()->get('command_publisher_spy'); + $this->assertSame([], $commandPublisher->publishedMessages()); + + /** @var Spy $spy */ + $spy = $kernel->getContainer()->get('spy'); + $this->assertSame([$command], $spy->handled); + } + + #[Test] + public function itHandlesUnionTypedCommandsInferredFromHandleMethodOnClassAttribute(): void + { + $kernel = static::createKernel(); + $kernel->boot(); + + $a = new AttrAsyncCommandA(); + $b = new AttrAsyncCommandB(); + + /** @var MessageBus $asynchronousCommandBus */ + $asynchronousCommandBus = $kernel->getContainer()->get('asynchronous_command_bus'); + $asynchronousCommandBus->handle($a); + $asynchronousCommandBus->handle($b); + + /** @var PublisherSpy $commandPublisher */ + $commandPublisher = $kernel->getContainer()->get('command_publisher_spy'); + $this->assertSame([], $commandPublisher->publishedMessages()); + + /** @var Spy $spy */ + $spy = $kernel->getContainer()->get('spy'); + $this->assertSame([$a, $b], $spy->handled); + } + + #[Test] + public function itHandlesUnionTypedCommandsWhenMethodIsSpecifiedOnClassAttribute(): void + { + $kernel = static::createKernel(); + $kernel->boot(); + + $c = new AttrAsyncCommandC(); + $d = new AttrAsyncCommandD(); + + /** @var MessageBus $asynchronousCommandBus */ + $asynchronousCommandBus = $kernel->getContainer()->get('asynchronous_command_bus'); + $asynchronousCommandBus->handle($c); + $asynchronousCommandBus->handle($d); + + /** @var PublisherSpy $commandPublisher */ + $commandPublisher = $kernel->getContainer()->get('command_publisher_spy'); + $this->assertSame([], $commandPublisher->publishedMessages()); + + /** @var Spy $spy */ + $spy = $kernel->getContainer()->get('spy'); + $this->assertSame([$c, $d], $spy->handled); + } + + #[Test] + public function itHonorsExplicitHandlesOnClassAttributeEvenWithUnionTypedMethod(): void + { + $kernel = static::createKernel(); + $kernel->boot(); + + $e = new AttrAsyncCommandE(); + $f = new AttrAsyncCommandF(); + + /** @var MessageBus $asynchronousCommandBus */ + $asynchronousCommandBus = $kernel->getContainer()->get('asynchronous_command_bus'); + $asynchronousCommandBus->handle($e); + + // Send unhandled command through the synchronous command bus to be published + /** @var MessageBus $commandBus */ + $commandBus = $kernel->getContainer()->get('command_bus'); + $commandBus->handle($f); + + /** @var Spy $spy */ + $spy = $kernel->getContainer()->get('spy'); + $this->assertSame([$e], $spy->handled, 'Only explicitly handled message should be handled'); + + /** @var PublisherSpy $commandPublisher */ + $commandPublisher = $kernel->getContainer()->get('command_publisher_spy'); + $this->assertSame([$f], $commandPublisher->publishedMessages(), 'Unhandled union branch should be published'); + } + #[Test] public function itNotifiesAsynchronousEventSubscribers(): void { diff --git a/packages/asynchronous-bundle/tests/Functional/config.yml b/packages/asynchronous-bundle/tests/Functional/config.yml index 6b0ca353..0f13a5e2 100644 --- a/packages/asynchronous-bundle/tests/Functional/config.yml +++ b/packages/asynchronous-bundle/tests/Functional/config.yml @@ -17,6 +17,41 @@ services: public: true class: SimpleBus\AsynchronousBundle\Tests\Functional\Spy + asynchronous_attribute_event_subscriber: + public: false + autoconfigure: true + class: SimpleBus\AsynchronousBundle\Tests\Functional\Attribute\AttributeAsyncEventSubscriber + arguments: + - '@spy' + + asynchronous_attribute_command_handler: + public: false + autoconfigure: true + class: SimpleBus\AsynchronousBundle\Tests\Functional\Attribute\AttributeAsyncCommandHandler + arguments: + - '@spy' + + asynchronous_attribute_union_command_handler: + public: false + autoconfigure: true + class: SimpleBus\AsynchronousBundle\Tests\Functional\Attribute\AttributeUnionAsyncCommandHandler + arguments: + - '@spy' + + asynchronous_attribute_union_command_handler_process: + public: false + autoconfigure: true + class: SimpleBus\AsynchronousBundle\Tests\Functional\Attribute\AttributeUnionAsyncCommandHandlerProcess + arguments: + - '@spy' + + asynchronous_attribute_union_command_handler_explicit: + public: false + autoconfigure: true + class: SimpleBus\AsynchronousBundle\Tests\Functional\Attribute\AttributeUnionAsyncCommandHandlerExplicit + arguments: + - '@spy' + synchronous_event_subscriber: public: false class: SimpleBus\AsynchronousBundle\Tests\Functional\EventSubscriber diff --git a/packages/symfony-bridge/src/Attribute/CommandHandler.php b/packages/symfony-bridge/src/Attribute/CommandHandler.php new file mode 100644 index 00000000..30c50954 --- /dev/null +++ b/packages/symfony-bridge/src/Attribute/CommandHandler.php @@ -0,0 +1,20 @@ +handles = $handles; + $this->method = $method; + } +} diff --git a/packages/symfony-bridge/src/Attribute/EventListener.php b/packages/symfony-bridge/src/Attribute/EventListener.php new file mode 100644 index 00000000..77efe3a5 --- /dev/null +++ b/packages/symfony-bridge/src/Attribute/EventListener.php @@ -0,0 +1,20 @@ +subscribesTo = $subscribesTo; + $this->method = $method; + } +} diff --git a/packages/symfony-bridge/src/DependencyInjection/AttributeTagResolver.php b/packages/symfony-bridge/src/DependencyInjection/AttributeTagResolver.php new file mode 100644 index 00000000..4d6cd175 --- /dev/null +++ b/packages/symfony-bridge/src/DependencyInjection/AttributeTagResolver.php @@ -0,0 +1,69 @@ +> + */ + public static function resolveTags( + Reflector $reflector, + ?string $messageType, + ?string $method, + string $typeKey, + ): array { + $resolvedMethod = $method + ?? ($reflector instanceof ReflectionMethod ? $reflector->getName() : null) + ?? ($reflector instanceof ReflectionClass && $reflector->hasMethod('handle') && !$reflector->hasMethod('__invoke') ? 'handle' : null); + + if (null === $messageType) { + $reflectionMethod = match (true) { + $reflector instanceof ReflectionMethod => $reflector, + $reflector instanceof ReflectionClass && null !== $method => $reflector->getMethod($method), + $reflector instanceof ReflectionClass && $reflector->hasMethod('__invoke') => $reflector->getMethod('__invoke'), + $reflector instanceof ReflectionClass && $reflector->hasMethod('handle') => $reflector->getMethod('handle'), + default => null, + }; + + if (null !== $reflectionMethod) { + $parameters = $reflectionMethod->getParameters(); + if (1 === count($parameters) && !$parameters[0]->isOptional()) { + $type = $parameters[0]->getType(); + + $types = match (true) { + $type instanceof ReflectionNamedType => [$type], + $type instanceof ReflectionUnionType => $type->getTypes(), + default => [], + }; + + $tags = []; + foreach ($types as $namedType) { + if (!$namedType instanceof ReflectionNamedType || $namedType->isBuiltin()) { + continue; + } + $tags[] = array_filter([ + $typeKey => $namedType->getName(), + 'method' => $resolvedMethod, + ]); + } + + return $tags; + } + } + } + + return [array_filter([ + $typeKey => $messageType, + 'method' => $resolvedMethod, + ])]; + } +} diff --git a/packages/symfony-bridge/src/SimpleBusCommandBusBundle.php b/packages/symfony-bridge/src/SimpleBusCommandBusBundle.php index 3328039b..17a27557 100644 --- a/packages/symfony-bridge/src/SimpleBusCommandBusBundle.php +++ b/packages/symfony-bridge/src/SimpleBusCommandBusBundle.php @@ -2,10 +2,15 @@ namespace SimpleBus\SymfonyBridge; +use Reflector; +use SimpleBus\SymfonyBridge\Attribute\CommandHandler; +use SimpleBus\SymfonyBridge\Attribute\EventListener; +use SimpleBus\SymfonyBridge\DependencyInjection\AttributeTagResolver; use SimpleBus\SymfonyBridge\DependencyInjection\CommandBusExtension; use SimpleBus\SymfonyBridge\DependencyInjection\Compiler\AutoRegister; use SimpleBus\SymfonyBridge\DependencyInjection\Compiler\ConfigureMiddlewares; use SimpleBus\SymfonyBridge\DependencyInjection\Compiler\RegisterHandlers; +use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -21,6 +26,24 @@ public function __construct(string $alias = 'command_bus') public function build(ContainerBuilder $container): void { + $container->registerAttributeForAutoconfiguration( + CommandHandler::class, + static function (ChildDefinition $definition, CommandHandler $attribute, Reflector $reflector): void { + foreach (AttributeTagResolver::resolveTags($reflector, $attribute->handles, $attribute->method, 'handles') as $tag) { + $definition->addTag('command_handler', $tag); + } + } + ); + + $container->registerAttributeForAutoconfiguration( + EventListener::class, + static function (ChildDefinition $definition, EventListener $attribute, Reflector $reflector): void { + foreach (AttributeTagResolver::resolveTags($reflector, $attribute->subscribesTo, $attribute->method, 'subscribes_to') as $tag) { + $definition->addTag('event_subscriber', $tag); + } + } + ); + $container->addCompilerPass( new AutoRegister('command_handler', 'handles'), PassConfig::TYPE_BEFORE_OPTIMIZATION, diff --git a/packages/symfony-bridge/tests/Functional/AttributesTest.php b/packages/symfony-bridge/tests/Functional/AttributesTest.php new file mode 100644 index 00000000..0e765de4 --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/AttributesTest.php @@ -0,0 +1,179 @@ + 'config_attributes']); + $container = self::getContainer(); + + $command = new AttrCommand(); + + $commandBus = $container->get('command_bus'); + $this->assertInstanceOf(MessageBus::class, $commandBus); + + $commandBus->handle($command); + + $this->assertTrue($command->isHandled()); + } + + #[Test] + public function itCanRegisterEventSubscriberUsingAttribute(): void + { + self::bootKernel(['environment' => 'config_attributes']); + $container = self::getContainer(); + + $event = new AttrEvent(); + + $eventBus = $container->get('event_bus'); + $this->assertInstanceOf(MessageBus::class, $eventBus); + + $eventBus->handle($event); + + $this->assertTrue($event->isHandledBy( + SmokeTest\Attributes\AttributeEventSubscriber::class + )); + } + + #[Test] + public function itCanRegisterUnionCommandHandlersUsingAttribute(): void + { + self::bootKernel(['environment' => 'config_attributes']); + $container = self::getContainer(); + + $a = new AttrUnionCommandA(); + $b = new AttrUnionCommandB(); + + /** @var MessageBus $commandBus */ + $commandBus = $container->get('command_bus'); + $commandBus->handle($a); + $commandBus->handle($b); + + $this->assertTrue($a->isHandled()); + $this->assertTrue($b->isHandled()); + } + + #[Test] + public function itCanRegisterUnionCommandHandlersWithMethodUsingAttribute(): void + { + self::bootKernel(['environment' => 'config_attributes']); + $container = self::getContainer(); + + $c = new AttrUnionCommandC(); + $d = new AttrUnionCommandD(); + + /** @var MessageBus $commandBus */ + $commandBus = $container->get('command_bus'); + $commandBus->handle($c); + $commandBus->handle($d); + + $this->assertTrue($c->isHandled()); + $this->assertTrue($d->isHandled()); + } + + #[Test] + public function itHonorsExplicitHandlesOnUnionCommandHandler(): void + { + self::bootKernel(['environment' => 'config_attributes']); + $container = self::getContainer(); + + $e = new AttrUnionCommandE(); + $f = new AttrUnionCommandF(); + + /** @var MessageBus $commandBus */ + $commandBus = $container->get('command_bus'); + $commandBus->handle($e); + $commandBus->handle($f); + + $this->assertTrue($e->isHandled()); + $this->assertTrue($f->isHandled()); + } + + #[Test] + public function itCanRegisterUnionEventListenersUsingAttribute(): void + { + self::bootKernel(['environment' => 'config_attributes']); + $container = self::getContainer(); + + $a = new AttrUnionEventA(); + $b = new AttrUnionEventB(); + + /** @var MessageBus $eventBus */ + $eventBus = $container->get('event_bus'); + $eventBus->handle($a); + $eventBus->handle($b); + + $this->assertTrue($a->isHandledBy(SmokeTest\Attributes\AttributeUnionEventListener::class)); + $this->assertTrue($b->isHandledBy(SmokeTest\Attributes\AttributeUnionEventListener::class)); + } + + #[Test] + public function itCanRegisterUnionEventListenersWithMethodUsingAttribute(): void + { + self::bootKernel(['environment' => 'config_attributes']); + $container = self::getContainer(); + + $c = new AttrUnionEventC(); + $d = new AttrUnionEventD(); + + /** @var MessageBus $eventBus */ + $eventBus = $container->get('event_bus'); + $eventBus->handle($c); + $eventBus->handle($d); + + $this->assertTrue($c->isHandledBy(SmokeTest\Attributes\AttributeUnionEventListenerOn::class)); + $this->assertTrue($d->isHandledBy(SmokeTest\Attributes\AttributeUnionEventListenerOn::class)); + } + + #[Test] + public function itHonorsExplicitSubscribesToOnUnionEventListener(): void + { + self::bootKernel(['environment' => 'config_attributes']); + $container = self::getContainer(); + + $g = new AttrUnionEventG(); + $h = new AttrUnionEventH(); + + /** @var MessageBus $eventBus */ + $eventBus = $container->get('event_bus'); + $eventBus->handle($g); + $eventBus->handle($h); + + $this->assertTrue($g->isHandledBy(SmokeTest\Attributes\AttributeUnionEventListenerExplicit::class)); + $this->assertFalse($h->isHandledBy(SmokeTest\Attributes\AttributeUnionEventListenerExplicit::class), 'Event not explicitly subscribed should not be handled'); + } + + protected static function getKernelClass(): string + { + return TestKernel::class; + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrCommand.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrCommand.php new file mode 100644 index 00000000..34310721 --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrCommand.php @@ -0,0 +1,18 @@ +handled; + } + + public function setHandled(bool $handled): void + { + $this->handled = $handled; + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrEvent.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrEvent.php new file mode 100644 index 00000000..a3a25f8b --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrEvent.php @@ -0,0 +1,24 @@ +handled, true); + } + + public function setHandledBy(object $subscriber): void + { + $this->handled[] = get_class($subscriber); + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionCommandA.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionCommandA.php new file mode 100644 index 00000000..883943d5 --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionCommandA.php @@ -0,0 +1,18 @@ +handled; + } + + public function setHandled(bool $handled): void + { + $this->handled = $handled; + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionCommandB.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionCommandB.php new file mode 100644 index 00000000..517422a3 --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionCommandB.php @@ -0,0 +1,18 @@ +handled; + } + + public function setHandled(bool $handled): void + { + $this->handled = $handled; + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionCommandC.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionCommandC.php new file mode 100644 index 00000000..679b1793 --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionCommandC.php @@ -0,0 +1,18 @@ +handled; + } + + public function setHandled(bool $handled): void + { + $this->handled = $handled; + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionCommandD.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionCommandD.php new file mode 100644 index 00000000..61c9ac0b --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionCommandD.php @@ -0,0 +1,18 @@ +handled; + } + + public function setHandled(bool $handled): void + { + $this->handled = $handled; + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionCommandE.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionCommandE.php new file mode 100644 index 00000000..415b3b36 --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionCommandE.php @@ -0,0 +1,18 @@ +handled; + } + + public function setHandled(bool $handled): void + { + $this->handled = $handled; + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionCommandF.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionCommandF.php new file mode 100644 index 00000000..ebcde888 --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionCommandF.php @@ -0,0 +1,18 @@ +handled; + } + + public function setHandled(bool $handled): void + { + $this->handled = $handled; + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionEventA.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionEventA.php new file mode 100644 index 00000000..80479525 --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionEventA.php @@ -0,0 +1,19 @@ +handled, true); + } + + public function setHandledBy(object $subscriber): void + { + $this->handled[] = get_class($subscriber); + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionEventB.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionEventB.php new file mode 100644 index 00000000..14a03da7 --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionEventB.php @@ -0,0 +1,19 @@ +handled, true); + } + + public function setHandledBy(object $subscriber): void + { + $this->handled[] = get_class($subscriber); + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionEventC.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionEventC.php new file mode 100644 index 00000000..0c9a5c2c --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionEventC.php @@ -0,0 +1,19 @@ +handled, true); + } + + public function setHandledBy(object $subscriber): void + { + $this->handled[] = get_class($subscriber); + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionEventD.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionEventD.php new file mode 100644 index 00000000..0f33de03 --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionEventD.php @@ -0,0 +1,19 @@ +handled, true); + } + + public function setHandledBy(object $subscriber): void + { + $this->handled[] = get_class($subscriber); + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionEventG.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionEventG.php new file mode 100644 index 00000000..615ffb7e --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionEventG.php @@ -0,0 +1,19 @@ +handled, true); + } + + public function setHandledBy(object $subscriber): void + { + $this->handled[] = get_class($subscriber); + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionEventH.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionEventH.php new file mode 100644 index 00000000..5536b0f0 --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttrUnionEventH.php @@ -0,0 +1,19 @@ +handled, true); + } + + public function setHandledBy(object $subscriber): void + { + $this->handled[] = get_class($subscriber); + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeCommandHandler.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeCommandHandler.php new file mode 100644 index 00000000..4f95aff1 --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeCommandHandler.php @@ -0,0 +1,14 @@ +setHandled(true); + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeEventSubscriber.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeEventSubscriber.php new file mode 100644 index 00000000..ec5d25d7 --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeEventSubscriber.php @@ -0,0 +1,14 @@ +setHandledBy($this); + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeUnionCommandHandler.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeUnionCommandHandler.php new file mode 100644 index 00000000..3f61dcc0 --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeUnionCommandHandler.php @@ -0,0 +1,14 @@ +setHandled(true); + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeUnionCommandHandlerExplicit.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeUnionCommandHandlerExplicit.php new file mode 100644 index 00000000..6d40dbaf --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeUnionCommandHandlerExplicit.php @@ -0,0 +1,15 @@ +setHandled(true); + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeUnionCommandHandlerProcess.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeUnionCommandHandlerProcess.php new file mode 100644 index 00000000..a71708b1 --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeUnionCommandHandlerProcess.php @@ -0,0 +1,14 @@ +setHandled(true); + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeUnionEventListener.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeUnionEventListener.php new file mode 100644 index 00000000..885a2ff4 --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeUnionEventListener.php @@ -0,0 +1,14 @@ +setHandledBy($this); + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeUnionEventListenerExplicit.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeUnionEventListenerExplicit.php new file mode 100644 index 00000000..6a463531 --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeUnionEventListenerExplicit.php @@ -0,0 +1,14 @@ +setHandledBy($this); + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeUnionEventListenerOn.php b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeUnionEventListenerOn.php new file mode 100644 index 00000000..8339ef19 --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/Attributes/AttributeUnionEventListenerOn.php @@ -0,0 +1,14 @@ +setHandledBy($this); + } +} diff --git a/packages/symfony-bridge/tests/Functional/SmokeTest/config_attributes.yml b/packages/symfony-bridge/tests/Functional/SmokeTest/config_attributes.yml new file mode 100644 index 00000000..4e9120ba --- /dev/null +++ b/packages/symfony-bridge/tests/Functional/SmokeTest/config_attributes.yml @@ -0,0 +1,8 @@ +imports: + - { resource: config.yml } + +services: + SimpleBus\SymfonyBridge\Tests\Functional\SmokeTest\Attributes\: + resource: '%kernel.project_dir%/Attributes/*' + public: false + autoconfigure: true