fix(test): remove stale phpstan ignores in CollectionNormalizerTest#8384
Merged
Conversation
composer.lock pins phpstan/phpstan to 2.2.3, and that version improved conditional-type narrowing: it now correctly infers that inside the `if (!$partial)` branch, $paginator is PaginatorInterface (which declares getLastPage()/getTotalItems()), whereas 2.1.x lost that correlation and reported a phpunit.mockMethod error there. The `@phpstan-ignore-line` comments suppressing that error are now unmatched, and reportUnmatchedIgnoredErrors turns unmatched ignores into hard failures. Removed the two stale ignores; the adjacent valid()/current() ignores above are still matched and left in place.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The failure
The PHPStan CI job (PHP 8.5) on
4.3fails:Root cause
composer.lockpinsphpstan/phpstanto2.2.3. That version improved conditional-type narrowing: inside theif (!$partial)branch ofnormalizePaginator(), PHPStan now correctly infers that$paginatoris aPaginatorInterface(which declaresgetLastPage()/getTotalItems()), because it correlates the$partialbool used to select the mocked interface with the laterif (!$partial)guard.Earlier PHPStan (2.1.x) lost that correlation and emitted a
phpunit.mockMethoderror ("Trying to mock an undefined method getLastPage() on ... PartialPaginatorInterface"), which the// @phpstan-ignore-linecomments on lines 128-129 suppressed.Now that the underlying error is no longer reported, those ignores are unmatched, and
reportUnmatchedIgnoredErrors(PHPStan default) turns them into non-ignorable hard failures.Fix
Remove the two stale
// @phpstan-ignore-linecomments. The code is untouched. The adjacentvalid()/current()ignores just above (lines 124-125) are still matched and left in place.Verified with PHPStan 2.2.3 (the exact locked version):
[OK] No errors. php-cs-fixer clean.