-
Notifications
You must be signed in to change notification settings - Fork 650
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
Invalid array callable wont get detected #6085
Comments
I found these snippets: https://psalm.dev/r/b661a0cb84<?php
function foo(callable $callback): void
{
$callback();
}
final class Bar
{
public static function baz(): void
{}
}
foo([Bar::class, 'baz', 1231233]);
|
Seems like a bundle of issues here I guess if I had to look at it, I'd start checking the first example and see how Psalm manage to flag the error (and where it comes from with --debug-emitted-issues) and then, I'd try to implement the same check when calling a Function or Method that has a callable parameter |
I found these snippets: https://psalm.dev/r/920f2bc3fa<?php
final class Bar
{
public static function baz(): void
{}
}
$a = [Bar::class, 'baz', 1231233];
assert(is_callable($a));
https://psalm.dev/r/88142fd37c<?php
final class Bar
{
public static function baz(): void
{}
}
assert(is_callable([Bar::class, 'baz', 1231233]));
https://psalm.dev/r/69df2d109b<?php
function foo(callable $callback): void
{
$callback();
}
final class Bar
{
public static function baz(): void
{}
}
$a = [Bar::class, 'baz'];
foo($a);
/** @psalm-trace $a */
|
Hey there,
an array-callable must consist of "object"/"class name" and "method/static method" information. Any other information leads to runtime issues:
https://psalm.dev/r/b661a0cb84
https://3v4l.org/rE02P
If you triage this bug, please let me know how to help.
The text was updated successfully, but these errors were encountered: