|
4 | 4 |
|
5 | 5 | use PHPStan\Reflection\ClassReflection; |
6 | 6 | use PHPStan\Reflection\ReflectionProvider; |
7 | | -use PHPStan\ShouldNotHappenException; |
8 | 7 | use Symfony\Component\Messenger\Handler\MessageSubscriberInterface; |
9 | 8 | use function class_exists; |
10 | 9 | use function count; |
@@ -96,14 +95,11 @@ private function guessHandledMessages(ClassReflection $reflectionClass): iterabl |
96 | 95 | $className = $reflectionClass->getName(); |
97 | 96 |
|
98 | 97 | foreach ($className::getHandledMessages() as $index => $value) { |
99 | | - try { |
100 | | - if (self::containOptions($index, $value)) { |
101 | | - yield $index => $value; |
102 | | - } else { |
103 | | - yield $value => ['method' => self::DEFAULT_HANDLER_METHOD]; |
104 | | - } |
105 | | - } catch (ShouldNotHappenException $e) { |
106 | | - continue; |
| 98 | + $containOptions = self::containOptions($index, $value); |
| 99 | + if ($containOptions === true) { |
| 100 | + yield $index => $value; |
| 101 | + } elseif ($containOptions === false) { |
| 102 | + yield $value => ['method' => self::DEFAULT_HANDLER_METHOD]; |
107 | 103 | } |
108 | 104 | } |
109 | 105 |
|
@@ -144,15 +140,15 @@ private function guessHandledMessages(ClassReflection $reflectionClass): iterabl |
144 | 140 | * @phpstan-assert-if-false =int $index |
145 | 141 | * @phpstan-assert-if-false =class-string $value |
146 | 142 | */ |
147 | | - private static function containOptions($index, $value): bool |
| 143 | + private static function containOptions($index, $value): ?bool |
148 | 144 | { |
149 | 145 | if (is_string($index) && class_exists($index) && is_array($value)) { |
150 | 146 | return true; |
151 | 147 | } elseif (is_int($index) && is_string($value) && class_exists($value)) { |
152 | 148 | return false; |
153 | 149 | } |
154 | 150 |
|
155 | | - throw new ShouldNotHappenException(); |
| 151 | + return null; |
156 | 152 | } |
157 | 153 |
|
158 | 154 | } |
0 commit comments