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

Psalm don't keep callable type in union types after condition #11062

Open
vjik opened this issue Aug 3, 2024 · 1 comment
Open

Psalm don't keep callable type in union types after condition #11062

vjik opened this issue Aug 3, 2024 · 1 comment

Comments

@vjik
Copy link
Contributor

vjik commented Aug 3, 2024

See https://psalm.dev/r/393eb25a8a

Copy link

I found these snippets:

https://psalm.dev/r/393eb25a8a
<?php

/**
 * @psalm-param array|callable():array $var
 */
function text(mixed $var): array
{   
    if (is_array($var)) {
        return $var;
    }

    /** @psalm-trace $var */

    return call_user_func($var);
}
Psalm output (using commit 16b24bd):

INFO: MixedReturnStatement - 14:12 - Could not infer a return type

INFO: Trace - 14:5 - $var: callable-object|callable-string

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