Merged
Conversation
thomascorthals
commented
Mar 17, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1179 +/- ##
==========================================
+ Coverage 98.21% 98.40% +0.18%
==========================================
Files 404 403 -1
Lines 10647 10646 -1
==========================================
+ Hits 10457 10476 +19
+ Misses 190 170 -20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Gave it a go to get the codebased analysed at PHPStan level 2. It shouldn't have BC breaks since the examples keep running without any changes. Unit and integration tests also keep running, changes in their code are just to get them to level 2 as well. I still prefer to have this coincide with a new major release though.
I set out with the idea that I didn't want an
ignoreErrorssection in the config. The very few things that do need ignoring are marked right in the code with an explanation why. E.g.:// @phpstan-ignore method.deprecated (we're calling a deprecated method on purpose)The bulk of the changes comes down to typehinting. Some of it can be fixed with corrected or more accurate typehints in method signatures. But there are numerous places where that wasn't possible because you can't narrow a parameter type in a child class. For instance, if an abstract parent method has an
AbstractComponent $componentparameter, the statical analysis doesn't "know" the object type in an overriding child method and you can't have a narrower type in the method signature. Annotating it as@param AbstractComponent&AnalyticsComponentin PHPDoc works around this limitation. The parser doesn't care, the human knows what is meant, PHPStan interprets it intuitively. If I'm missing something here and there's a better way around this contravariance limitation, let me know!Where it made sense in tests, I went with
assertInstanceOf()instead of typehint annotations because that also narrows down the type for PHPStan.