phpstan-wordpress
phpstan-wordpress copied to clipboard
Named arguments break add_filter/add_action callback check
Reproduce:
add_filter('filter', function($one, $two) {
return 123;
}, accepted_args: 2);
Expected: No errors
Actual
Callback expects 2 parameters, $accepted_args is set to 1.
Hello @marijnvdwerf! 👋🏻
Thank you for your report. Yes, this feature of PHP is not supported.
If you take a look at the WordPress ecosystem (not core only), you see that WordPress installations should run on PHP 7.4. Maybe next year it will be 8.0 (or 8.1) compatible. Core stats show this: https://wordpress.org/about/stats/#php_versions
A second thought. Explicit is better than implicit.
add_filter(
'filter',
function ($one, $two) {
return 123;
},
10,
2
);