Ignore PHPStan error
21 September 2025 (Updated 21 September 2025)
Ignore a particular error
// @phpstan-ignore variable.undefined
echo $foo;
Ignore a particular error with a message
echo $foo; // @phpstan-ignore variable.undefined (Because we are lazy)
Ignore all errors on line
// @phpstan-ignore-next-line
echo $foo;
Ignore errors project-wide via regex
parameters:
ignoreErrors:
- '#Call to an undefined method [a-zA-Z0-9\\_]+::doFoo\(\)#'
- '#Call to an undefined method [a-zA-Z0-9\\_]+::doBar\(\)#'
Ignore errors for specific files via regex
parameters:
ignoreErrors:
-
message: '#Access to an undefined property [a-zA-Z0-9\\_]+::\$foo#'
path: some/dir/SomeFile.php
-
message: '#Call to an undefined method [a-zA-Z0-9\\_]+::doBar\(\)#'
paths:
- some/dir/*
- other/dir/*
-
messages:
- '#Call to an undefined method [a-zA-Z0-9\\_]+::doFooFoo\(\)#'
- '#Call to an undefined method [a-zA-Z0-9\\_]+::doFooBar\(\)#'
path: other/dir/AnotherFile.php
-
messages:
- '#Call to an undefined method [a-zA-Z0-9\\_]+::doFooFoo\(\)#'
- '#Call to an undefined method [a-zA-Z0-9\\_]+::doFooBar\(\)#'
paths:
- some/foo/dir/*
- other/foo/dir/*
-
message: '#Call to an undefined method [a-zA-Z0-9\\_]+::doFoo\(\)#'
path: other/dir/DifferentFile.php
count: 2 # optional
- '#Other error to ignore everywhere#'
Ignore particular errors
parameters:
ignoreErrors:
-
identifiers:
- property.notFound
- property.neverWritten
Links
Tagged:
PHP tooling