website/errors/method.nameCase.md
<?php declare(strict_types = 1);
class Foo
{
public function fooBar(): void
{
}
}
function (Foo $foo): void {
$foo->foobar(); // error: Call to method Foo::fooBar() with incorrect case: foobar
};
While PHP method names are case-insensitive and foobar() will work at runtime, using a different case than the method declaration is inconsistent and makes code harder to read and maintain. This check helps enforce consistent casing across the codebase.
This error is reported only when the checkFunctionNameCase option is enabled.
Use the exact same casing as in the method declaration.
function (Foo $foo): void {
- $foo->foobar();
+ $foo->fooBar();
};