Skip to content

Commit 55d85e5

Browse files
wephruudk
authored andcommitted
Ignore public methods with a single non-class arguments during auto register
1 parent e6629a4 commit 55d85e5

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/DependencyInjection/Compiler/AutoRegister.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace SimpleBus\SymfonyBridge\DependencyInjection\Compiler;
44

5-
use RuntimeException;
65
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
76
use Symfony\Component\DependencyInjection\ContainerBuilder;
87

@@ -54,16 +53,11 @@ public function process(ContainerBuilder $container)
5453

5554
$parameters = $method->getParameters();
5655

57-
// if no param or optional param, skip
58-
if (count($parameters) !== 1 || $parameters[0]->isOptional()) {
56+
// if no param, optional param or non-class param, skip
57+
if (count($parameters) !== 1 || $parameters[0]->isOptional() || $parameters[0]->getClass() === null) {
5958
continue;
6059
}
6160

62-
if ($parameters[0]->getClass() === null) {
63-
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,
64-
$parameters[0]->getName(), $method->getName()));
65-
}
66-
6761
// get the class name
6862
$handles = $parameters[0]->getClass()->getName();
6963

tests/Functional/SmokeTest/Auto/AutoCommandHandlerUsingPublicMethod.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@ public function someHandleMethod(AutoCommand2 $command)
88
{
99
$command->setHandled(true);
1010
}
11+
12+
public function randomPublicMethod($value)
13+
{
14+
15+
}
1116
}

tests/Functional/SmokeTest/Auto/AutoEventSubscriberUsingPublicMethod.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ public function someOtherEventHandler(AutoEvent3 $event)
2323
{
2424
$event->setHandledBy($this);
2525
}
26+
27+
public function randomPublicMethod($value)
28+
{
29+
30+
}
2631
}

0 commit comments

Comments
 (0)