From 8ec274534895109e08795ac6d40ce41ec6798f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Mirtes?= Date: Thu, 3 Dec 2026 11:54:46 +0000 Subject: [PATCH] Split containOptions() into two bool-returning checks Conditional @phpstan-assert-if-true/-if-false tags require a bool return type (assert.nonBool, checkAssertTagsCompatibility in bleeding edge since phpstan/phpstan-src 61027562a). containOptions() returned ?bool, and its -if-false assertion would also apply to the null it returns for entries that are neither form. Amp-Thread-ID: https://ampcode.com/threads/T-01a19770-5331-74b2-963f-e324ae0f7635 --- src/Symfony/MessageMapFactory.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Symfony/MessageMapFactory.php b/src/Symfony/MessageMapFactory.php index 6d7e2e91..26850482 100644 --- a/src/Symfony/MessageMapFactory.php +++ b/src/Symfony/MessageMapFactory.php @@ -94,10 +94,9 @@ private function guessHandledMessages(ClassReflection $reflectionClass): iterabl $className = $reflectionClass->getName(); foreach ($className::getHandledMessages() as $index => $value) { - $containOptions = self::containOptions($index, $value); - if ($containOptions === true) { + if (self::isMessageWithOptions($index, $value)) { yield $index => $value; - } elseif ($containOptions === false) { + } elseif (self::isMessageWithoutOptions($index, $value)) { yield $value => ['method' => self::DEFAULT_HANDLER_METHOD]; } } @@ -136,18 +135,21 @@ private function guessHandledMessages(ClassReflection $reflectionClass): iterabl * @param mixed $value * @phpstan-assert-if-true =class-string $index * @phpstan-assert-if-true =array $value - * @phpstan-assert-if-false =int $index - * @phpstan-assert-if-false =class-string $value */ - private static function containOptions($index, $value): ?bool + private static function isMessageWithOptions($index, $value): bool { - if (is_string($index) && class_exists($index) && is_array($value)) { - return true; - } elseif (is_int($index) && is_string($value) && class_exists($value)) { - return false; - } + return is_string($index) && class_exists($index) && is_array($value); + } - return null; + /** + * @param mixed $index + * @param mixed $value + * @phpstan-assert-if-true =int $index + * @phpstan-assert-if-true =class-string $value + */ + private static function isMessageWithoutOptions($index, $value): bool + { + return is_int($index) && is_string($value) && class_exists($value); } }