Skip to content

Split containOptions() into two bool-returning checks - #534

Merged
ondrejmirtes merged 1 commit into
2.1.xfrom
bool-returning-message-entry-checks
Dec 3, 2026
Merged

ondrejmirtes merged 1 commit into
2.1.xfrom
bool-returning-message-entry-checks

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

The Extension tests in phpstan/phpstan fail for phpstan-symfony since PHAR ef67a9f: https://github.com/phpstan/phpstan/actions/runs/47090047476.

src/Symfony/MessageMapFactory.php:142  PHPDoc tag @phpstan-assert-if-false above method PHPStan\Symfony\MessageMapFactory::containOptions() requires return type bool, bool|null given.  [assert.nonBool]
src/Symfony/MessageMapFactory.php:142  PHPDoc tag @phpstan-assert-if-true above method ... requires return type bool, bool|null given.  [assert.nonBool]

phpstan-src 61027562a added the requirement that conditional asserts have a bool return type, checked under bleedingEdge's checkAssertTagsCompatibility. This repository includes bleedingEdge.

containOptions() returned ?bool, so its -if-false assertion would also apply to the null returned for entries in neither form. This PR replaces it with isMessageWithOptions() and isMessageWithoutOptions(). Both return bool and each keeps only the -if-true asserts of its branch. guessHandledMessages() yields exactly what it did before.

Verified locally:

  • vendor/bin/phpstan analyse -c phpstan.neon with the phpstan/phpstan ef67a9f PHAR reports no errors; before this change it reported the 2 errors above.
  • tests/Type/Symfony passes (396 tests).
  • phpcs passes on the file.

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
@ondrejmirtes
ondrejmirtes merged commit c463024 into 2.1.x Dec 3, 2026
51 checks passed
@ondrejmirtes
ondrejmirtes deleted the bool-returning-message-entry-checks branch December 3, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant