Skip to content

Commit 5cba4ba

Browse files
Bartłomiej Nowakbnowak
Bartłomiej Nowak
authored andcommitted
addressed rest of todo comments
1 parent 46e0cc8 commit 5cba4ba

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/Symfony/MessageMapFactory.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use PHPStan\Reflection\ClassReflection;
66
use PHPStan\Reflection\MissingMethodFromReflectionException;
7-
use PHPStan\Reflection\ParametersAcceptorSelector;
87
use PHPStan\Reflection\ReflectionProvider;
98
use Symfony\Component\Messenger\Handler\MessageSubscriberInterface;
109
use function count;
@@ -15,6 +14,7 @@
1514
final 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
}

tests/Type/Symfony/data/messenger_handle_trait.php

-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ public function handleString(StringQuery $query): string
4949
{
5050
return 'string result';
5151
}
52-
53-
// todo add handle method with union return type?
5452
}
5553

5654
class TaggedQuery {}

0 commit comments

Comments
 (0)