phpstan-wordpress
phpstan-wordpress copied to clipboard
Spot non-existent method/function in remove_action()
remove_action('wp_enqueue_scripts', [$theme, 'wp_common_block_scripts_and_styles']);
This triggered no error on level 5. How could that be?
ps. wp_common_block_scripts_and_styles is a global function from core
This is expected behaviour. The $callback parameter doesn't have to be valid.
* @param callable|string|array $callback The name of the function which should be removed.
* This function can be called unconditionally to speculatively remove
* a callback that may or may not exist.
Thank you, John.
(For extraterrestrial aliens 👽) could you add something like HookCallbackRule that checks for callback existence in hooking function? And has a parameter that activates it, so it is off by default (for earthlings).
I'd rather not 🤣