Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.
Code example #
<?php declare(strict_types = 1);
function doFoo($this)
{
}
Why is it reported? #
$this is a reserved variable in PHP that refers to the current object instance inside a class. Using it as a parameter name is not allowed — PHP will produce a fatal error if $this is used as a parameter in a method, and while it may not always error in a standalone function, it creates misleading code that suggests an object context where there is none.
How to fix it #
Rename the parameter:
-function doFoo($this)
+function doFoo($value)
{
}
Non-ignorable error #
This error cannot be ignored using @phpstan-ignore or the ignoreErrors configuration. Non-ignorable errors indicate code that would cause a crash or a fatal error at runtime, or a fundamental problem in the analysed code that must be addressed.
Rules that report this error #
- PHPStan\Rules\Functions\InvalidParameterNameRule [1]