Repository navigation
Add @phpstan-ignore-var to keep inline @var tags from overriding inferred types - #6887
Open
jack-worman wants to merge 9 commits into
Open
jack-worman wants to merge 9 commits into
jack-worman wants to merge 9 commits into
Conversation
jack-worman
marked this pull request as draft
October 30, 2026 03:18
@phpstan-ignore-var to ignore @var in the same PHPDoc@phpstan-ignore-var to keep inline @var tags from overriding inferred types
jack-worman
marked this pull request as ready for review
October 30, 2026 04:11
Collaborator
|
This pull request has been marked as ready for review. |
…n-ignore-var` errors
- recognise the tag on the line of a `@var` tag, as in `/** @var Foo $x @phpstan-ignore-var */` - do not check ignored `@var` tags above `global` and `static` statements against an earlier variable - report the tag above parameters, closures and arrow functions and at the end of a class body
…one-line form - report the tag above a closure or arrow function passed as an argument or written as an array item, whose PHPDoc php-parser attaches to the argument or the item - report it above `elseif`, `else` and `catch`, where no `@var` applies, instead of checking the ignored tags there - recognise it in a `@var` description only at the start, so a description that mentions it keeps the `@var` applied - cover an ignored `@var` over a variable that may not be defined
jack-worman
force-pushed
the
phpstan-ignore-var
branch
from
October 30, 2026 12:56
9a4368f to
de41c3a
Compare
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.
Adds
@phpstan-ignore-varfor inline@vartags kept only for IDE autocompletion: PHPStan keeps the type it infers instead of applying them, but unlike Psalm's@psalm-ignore-varit still checks them.@vartag in the PHPDoc (@var,@phpstan-var,@psalm-var,@phan-var) and can also directly follow the@vartag:/** @var Foo $foo @phpstan-ignore-var */.@var.@vartags have none (above declarations, parameters, closures,elseif,elseandcatch, at the end of a class body) and in a PHPDoc without a@vartag.@phpstan-ignorecomment parser skips it instead of reporting a parse error.Complements #6888: a redundant tag the IDE still needs can be kept with
@phpstan-ignore-var.Related: phpstan/phpstan#9049