You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Hooks/Docs: wp_die_*_handler filters (×6) — @param callable but string literal is passed as default #23
Six wp_die_*_handler filters in wp-includes/functions.php document their parameter as @param callable $callback but pass a string literal as the default value. In PHP, a string is a valid callable (it's a function name), but PHPStan's strict type checking does not consider string to be identical to callable, causing a reported type mismatch.
PHP allows a string function name as a callable, but PHPStan treats callable and string as distinct types. The default value '_ajax_wp_die_handler' is inferred as string, which is narrower than callable.
Fix
Update all six @param tags to include string in the type union, reflecting that the default (and typical) value is a string function name:
- * @param callable $callback Callback function name.+ * @param callable|string $callback Callback function name.
Alternatively, use @param callable-string if the intent is to restrict to named functions only (PHPStan understands callable-string as a callable that is specifically a string).
False positive — the @param callable type is correct. The default value is a string function name, but the filter can legitimately return any callable (closure, array, etc.). The mismatch is a limitation of the custom PHPStan rule comparing the documented type against the inferred type of the default value.
Activity
apermo commentedon Mar 8, 2026
False positive — the
@param callabletype is correct. The default value is a string function name, but the filter can legitimately return any callable (closure, array, etc.). The mismatch is a limitation of the custom PHPStan rule comparing the documented type against the inferred type of the default value.