44
55use PHPStan \Reflection \ClassReflection ;
66use PHPStan \Reflection \MissingMethodFromReflectionException ;
7- use PHPStan \Reflection \ParametersAcceptorSelector ;
87use PHPStan \Reflection \ReflectionProvider ;
98use Symfony \Component \Messenger \Handler \MessageSubscriberInterface ;
109use function count ;
1514final class MessageMapFactory
1615{
1716
17+ private const MESSENGER_HANDLER_TAG = 'messenger.message_handler ' ;
1818 private const DEFAULT_HANDLER_METHOD = '__invoke ' ;
1919
2020 /** @var ReflectionProvider */
@@ -36,15 +36,12 @@ public function create(): MessageMap
3636 foreach ($ this ->serviceMap ->getServices () as $ service ) {
3737 $ serviceClass = $ service ->getClass ();
3838
39- // todo handle abstract/parent services somehow?
4039 if (is_null ($ serviceClass )) {
4140 continue ;
4241 }
4342
4443 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 ) {
4845 continue ;
4946 }
5047
@@ -59,9 +56,10 @@ public function create(): MessageMap
5956
6057 foreach ($ handles as $ messageClassName => $ options ) {
6158 $ methodReflection = $ reflectionClass ->getNativeMethod ($ options ['method ' ] ?? self ::DEFAULT_HANDLER_METHOD );
62- $ variant = ParametersAcceptorSelector::selectSingle ($ methodReflection ->getVariants ());
6359
64- $ returnTypesMap [$ messageClassName ][] = $ variant ->getReturnType ();
60+ foreach ($ methodReflection ->getVariants () as $ variant ) {
61+ $ returnTypesMap [$ messageClassName ][] = $ variant ->getReturnType ();
62+ }
6563 }
6664 }
6765 }
0 commit comments