Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docbloc: callable() is not a valid method #10908

Open
gmazzap opened this issue Apr 15, 2024 · 1 comment
Open

Docbloc: callable() is not a valid method #10908

gmazzap opened this issue Apr 15, 2024 · 1 comment

Comments

@gmazzap
Copy link

gmazzap commented Apr 15, 2024

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

Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant