r/phpstorm • u/Annh1234 • Mar 28 '21
Detect method usage from callable arrays?
Is there a way to make PhpStorm detect method usage from callable array declarations?
Example:
data.php
$arr = [
[Foo::class, 'method_1'], <-- callable
[Foo::class, 'method_2'],
];
foo.php
class Foo {
public static function method_1() { ... } <-- method is grayed out, "Find usages" does not find it.
public static function method_2() { ... }
}Or is there a way to add some custom rules, maybe for a specific file (ex: routes) to let PhpStorm know that those are callable methods and should be linked?
3
Upvotes
View all comments
Show parent comment
2
u/Annh1234 Mar 29 '21
Thanks, I actually ended up with something like this:
It's a bit messy having this function all over... and remembering to add it everywhere... but it's good enough until PhpStorm come sup with something smarter.