psalm
psalm copied to clipboard
Docbloc: callable() is not a valid method
Psalm, rightfully, does not complain when encountering an actual method named callable
.
But it does complain if the method is in a @method
docblock.
Note: this is specific to "callable". Method named as other types such as "string", "int" or "bool" do not cause any issue.
See https://psalm.dev/r/c91fa34de9
I found these snippets:
https://psalm.dev/r/c91fa34de9
<?php
/**
* @method static Type string()
* @method static Type int()
* @method static Type float()
*
* @method Type callable()
*/
class Foo
{
public function __call(string $name, array $arguments): string
{
if ($name === 'callable') {
return 'Callable is a valid method name';
}
throw new \Error('Invalid method');
}
}
class Bar
{
public function callable(): void
{
}
public function string(): void
{
}
public function int(): void
{
}
public function float(): void
{
}
}
Psalm output (using commit 08afc45):
ERROR: InvalidDocblock - 10:7 - callable() is not a valid method in docblock for Foo