Skip to content

Raise PHPStan to the max level - #158

Merged
chrisjenkinson merged 3 commits into
masterfrom
claude/phpstan-level
Sep 25, 2026
Merged

chrisjenkinson merged 3 commits into
masterfrom
claude/phpstan-level

Conversation

@chrisjenkinson

@chrisjenkinson chrisjenkinson commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

This raises PHPStan from level 5 to max for src/ and tests/ and fixes the 25 errors that surfaced:

  • Arrays have element types in docblocks, for example RegexFinder::getMatches(), MatchedText::getAll(), NodeTraverser::traverseChildren() and the AmbiguousTokenFoundException getters.
  • TokenStream::expectTokenType() and expectTokenTypes() check the current token for null directly instead of relying on a separate count.
  • TokenInterface gains getText(): string for the text a token consumed. Token checks when it's constructed that its all value is a string, so the lexer and __toString() can rely on it without a check of their own. getValue('all') still works.
  • NodeTraverserTest asserts that traverse() 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 TokenInterface need getText(), and Token throws InvalidArgumentException if its all value is missing or isn't a string.

@chrisjenkinson
chrisjenkinson merged commit 108a999 into master Sep 25, 2026
4 checks passed
@chrisjenkinson
chrisjenkinson deleted the claude/phpstan-level branch September 25, 2026 10:20
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