When editing wordpress code in Visual Studio Code,
if I have a function definition and than I use it as a callback for a call to add_action or add_filter like this:
function myCallback() {
//do some stuff
}
add_action('init', 'myCallback') ;
but because its used as a string its not counted as a reference to the function and the intelisense says 0 references above my function which is true to some degree but also false and misleading in the practical sense.
Can I do something to tell visual studio code to add a reference to that function?
I was hoping I maybe could do something like (This is not real working code...):
function myCallback() {
//do some stuff
}
add_action('init', myCallback.name) ;
i.e. get the name of myCallbck by referencing a member field or method of it.
or (This is again not a currently working solution - just an idea...)
add_action('init','myCallback' /* @references:myCallback */)
i.e. by adding some comment that intelephanse could use to understand that there is a reference this it would otherwise miss.
If you are using PHP 8.1, you can use the first class callable syntax
I tried DEVSENSE's PHP extension, the following callable form can be recognized as a reference.