Closed bapcltd-marv closed 4 years ago
Thanks @bapcltd-marv, I'm still new to Psalm, but here's a copy of the function in the stubs file of this repo:
❯ rg -pS add_theme_support -C 7
stubs/wordpress.php
39818- }
39819- /**
39820- * @param string $feature
39821- * @param mixed $args
39822- *
39823- * @return bool|null
39824- */
39825: function add_theme_support($feature, $args)
The source as per the link has:
* @since 5.3.0 Formalized the existing and already documented `...$args` parameter
* by adding it to the function signature.
*
* @global array $_wp_theme_features
*
* @param string $feature The feature being added. Likely core values include 'post-formats', 'post-thumbnails',
* 'custom-header', 'custom-background', 'custom-logo', 'menus', 'automatic-feed-links',
* 'html5', 'title-tag', 'customize-selective-refresh-widgets', 'starter-content',
* 'responsive-embeds', 'align-wide', 'dark-editor-style', 'disable-custom-colors',
* 'disable-custom-font-sizes', 'editor-color-palette', 'editor-font-sizes',
* 'editor-styles', and 'wp-block-styles'.
* @param mixed ...$args Optional extra arguments to pass along with certain features.
* @return void|bool False on failure, void otherwise.
*/
function add_theme_support( $feature, ...$args ) {
So the stubs here are not using the spread operator ...$args
, and also omits the optional
@param
context.
I'm guessing this is due to the stubs generator @joehoyle?
Hrm yeah I think this is a problem with the stub generation. I think it's reading the docblock which is mixed
which I don't think means optional. I think variadics should always be optional though?
does the stub generator check for ReflectionParameter::isVariadic()
?
Not sure what version of wordpress is targeted/supported, but currently getting
TooFewArguments - dist\functions.php:37:2 - Too few arguments for add_theme_support - expecting 2 but saw 1
:https://github.com/WordPress/WordPress/blob/4d8ef4961891bb2187a2bd9a44abae97145ffc37/wp-includes/theme.php#L2472