4
4
5
5
use PHPStan \Reflection \ClassReflection ;
6
6
use PHPStan \Reflection \MissingMethodFromReflectionException ;
7
- use PHPStan \Reflection \ParametersAcceptorSelector ;
8
7
use PHPStan \Reflection \ReflectionProvider ;
9
8
use Symfony \Component \Messenger \Handler \MessageSubscriberInterface ;
10
9
use function count ;
15
14
final class MessageMapFactory
16
15
{
17
16
17
+ private const MESSENGER_HANDLER_TAG = 'messenger.message_handler ' ;
18
18
private const DEFAULT_HANDLER_METHOD = '__invoke ' ;
19
19
20
20
/** @var ReflectionProvider */
@@ -36,15 +36,12 @@ public function create(): MessageMap
36
36
foreach ($ this ->serviceMap ->getServices () as $ service ) {
37
37
$ serviceClass = $ service ->getClass ();
38
38
39
- // todo handle abstract/parent services somehow?
40
39
if (is_null ($ serviceClass )) {
41
40
continue ;
42
41
}
43
42
44
43
foreach ($ service ->getTags () as $ tag ) {
45
- // todo could there be more tags with the same name for the same service?
46
- // todo check if message handler tag name is constant or configurable
47
- if ($ tag ->getName () !== 'messenger.message_handler ' ) {
44
+ if ($ tag ->getName () !== self ::MESSENGER_HANDLER_TAG ) {
48
45
continue ;
49
46
}
50
47
@@ -59,9 +56,10 @@ public function create(): MessageMap
59
56
60
57
foreach ($ handles as $ messageClassName => $ options ) {
61
58
$ methodReflection = $ reflectionClass ->getNativeMethod ($ options ['method ' ] ?? self ::DEFAULT_HANDLER_METHOD );
62
- $ variant = ParametersAcceptorSelector::selectSingle ($ methodReflection ->getVariants ());
63
59
64
- $ returnTypesMap [$ messageClassName ][] = $ variant ->getReturnType ();
60
+ foreach ($ methodReflection ->getVariants () as $ variant ) {
61
+ $ returnTypesMap [$ messageClassName ][] = $ variant ->getReturnType ();
62
+ }
65
63
}
66
64
}
67
65
}
0 commit comments