Error Identifier: staticMethod.nameCase
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);
class Foo
{
public static function fooBar(): void
{
}
}
Foo::foobar();
Why is it reported? #
The static method is being called with a different letter case than how it is defined. While PHP method calls are case-insensitive and the code will work at runtime, using incorrect case is inconsistent and makes the code harder to read and maintain.
This error is only reported when the checkFunctionNameCase configuration option is enabled.
How to fix it #
Match the case of the method name exactly as it is defined.
-Foo::foobar();
+Foo::fooBar();
How to ignore this error #
You can use the identifier staticMethod.nameCase to ignore this error using a comment:
// @phpstan-ignore staticMethod.nameCase
codeThatProducesTheError();
You can also use only the identifier key to ignore all errors of the same type in your configuration file in the ignoreErrors parameter:
parameters:
ignoreErrors:
-
identifier: staticMethod.nameCase