Repository navigation
Raise PHPStan to the max level - #158
Merged
Merged
Conversation
chrisjenkinson
force-pushed
the
claude/phpstan-level
branch
from
September 25, 2026 10:15
2045fcb to
72ded76
Compare
…ding a Token instead of asserting
…eInterface example
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.
This raises PHPStan from level 5 to
maxforsrc/andtests/and fixes the 25 errors that surfaced:RegexFinder::getMatches(),MatchedText::getAll(),NodeTraverser::traverseChildren()and theAmbiguousTokenFoundExceptiongetters.TokenStream::expectTokenType()andexpectTokenTypes()check the current token fornulldirectly instead of relying on a separate count.TokenInterfacegainsgetText(): stringfor the text a token consumed.Tokenchecks when it's constructed that itsallvalue is a string, so the lexer and__toString()can rely on it without a check of their own.getValue('all')still works.NodeTraverserTestasserts thattraverse()returned a node before using it, since it now returns?NodeInterface.spec/is still excluded. PHPStan can't follow phpspec's magic methods and reports around 300 errors there, and the only phpspec extension for PHPStan targets PHPStan 0.11 and phpspec 6.Breaking changes: implementations of
TokenInterfaceneedgetText(), andTokenthrowsInvalidArgumentExceptionif itsallvalue is missing or isn't a string.