diff --git a/src/DependencyInjection/Compiler/AutoRegister.php b/src/DependencyInjection/Compiler/AutoRegister.php index 7bfbd16..44138da 100644 --- a/src/DependencyInjection/Compiler/AutoRegister.php +++ b/src/DependencyInjection/Compiler/AutoRegister.php @@ -2,7 +2,6 @@ namespace SimpleBus\SymfonyBridge\DependencyInjection\Compiler; -use RuntimeException; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -54,16 +53,11 @@ public function process(ContainerBuilder $container) $parameters = $method->getParameters(); - // if no param or optional param, skip - if (count($parameters) !== 1 || $parameters[0]->isOptional()) { + // if no param, optional param or non-class param, skip + if (count($parameters) !== 1 || $parameters[0]->isOptional() || $parameters[0]->getClass() === null) { continue; } - if ($parameters[0]->getClass() === null) { - throw new RuntimeException(sprintf('Could not get auto register class %s because the first parameter %s of public method %s should be have a class typehint. Either specify the typehint, make the function non-public, or disable auto registration.', $method->class, - $parameters[0]->getName(), $method->getName())); - } - // get the class name $handles = $parameters[0]->getClass()->getName(); diff --git a/tests/Functional/SmokeTest/Auto/AutoCommandHandlerUsingPublicMethod.php b/tests/Functional/SmokeTest/Auto/AutoCommandHandlerUsingPublicMethod.php index 4dc103b..cff0d9c 100644 --- a/tests/Functional/SmokeTest/Auto/AutoCommandHandlerUsingPublicMethod.php +++ b/tests/Functional/SmokeTest/Auto/AutoCommandHandlerUsingPublicMethod.php @@ -8,4 +8,9 @@ public function someHandleMethod(AutoCommand2 $command) { $command->setHandled(true); } + + public function randomPublicMethod($value) + { + + } } diff --git a/tests/Functional/SmokeTest/Auto/AutoEventSubscriberUsingPublicMethod.php b/tests/Functional/SmokeTest/Auto/AutoEventSubscriberUsingPublicMethod.php index b3dd606..c760051 100644 --- a/tests/Functional/SmokeTest/Auto/AutoEventSubscriberUsingPublicMethod.php +++ b/tests/Functional/SmokeTest/Auto/AutoEventSubscriberUsingPublicMethod.php @@ -23,4 +23,9 @@ public function someOtherEventHandler(AutoEvent3 $event) { $event->setHandledBy($this); } + + public function randomPublicMethod($value) + { + + } }