diff --git a/.travis.yml b/.travis.yml index 8136830..83d2cc4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,3 +48,5 @@ script: - "git diff --exit-code" # Execute stubs - "php -f wordpress-stubs.php" + # Analyse our code + - "vendor/bin/phpstan" diff --git a/composer.json b/composer.json index 7ffc655..70ae0e5 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,9 @@ }, "require-dev": { "php": "~7.3 || ~8.0", - "php-stubs/generator": "^0.7.0", + "phpdocumentor/reflection-docblock": "^5.3", + "php-stubs/generator": "^0.8.0", + "phpstan/phpstan": "^1.2", "nikic/php-parser": "< 4.12.0" }, "suggest": { diff --git a/generate.sh b/generate.sh index c4bd635..6f87b34 100755 --- a/generate.sh +++ b/generate.sh @@ -18,6 +18,7 @@ fi "$(dirname "$0")/vendor/bin/generate-stubs" \ --force \ --finder=finder.php \ + --visitor=visitor.php \ --header="$HEADER" \ --functions \ --classes \ diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..cb6faa4 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +parameters: + level: 8 + paths: + - visitor.php diff --git a/visitor.php b/visitor.php new file mode 100644 index 0000000..54456c9 --- /dev/null +++ b/visitor.php @@ -0,0 +1,242 @@ +docBlockFactory = \phpDocumentor\Reflection\DocBlockFactory::createInstance(); + } + + public function enterNode(Node $node) + { + parent::enterNode($node); + + if (!($node instanceof Function_) && !($node instanceof ClassMethod)) { + return null; + } + + $docComment = $node->getDocComment(); + + if (!($docComment instanceof Doc)) { + return null; + } + + $newDocComment = $this->addArrayHashNotation($docComment); + + if ($newDocComment !== null) { + $node->setDocComment($newDocComment); + } + + return null; + } + + private function addArrayHashNotation(Doc $docComment): ?Doc + { + $docCommentText = $docComment->getText(); + + try { + $docblock = $this->docBlockFactory->create($docCommentText); + } catch ( \RuntimeException $e ) { + return null; + } catch ( \InvalidArgumentException $e ) { + return null; + } + + /** @var \phpDocumentor\Reflection\DocBlock\Tags\Param[] */ + $params = $docblock->getTagsByName('param'); + + /** @var \phpDocumentor\Reflection\DocBlock\Tags\Return_[] */ + $returns = $docblock->getTagsByName('return'); + + if (!$params && !$returns) { + return null; + } + + $additions = []; + + foreach ($params as $param) { + $addition = $this->getAdditionFromParam($param); + + if ($addition !== null) { + $additions[] = $addition; + } + } + + if ($returns) { + $addition = $this->getAdditionFromReturn($returns[0]); + + if ($addition !== null) { + $additions[] = $addition; + } + } + + if (!$additions) { + return null; + } + + $newDocComment = sprintf( + "%s\n%s\n */", + substr($docCommentText, 0, -4), + implode("\n", $additions) + ); + + return new Doc($newDocComment, $docComment->getLine(), $docComment->getFilePos()); + } + + private function getAdditionFromParam(Param $tag): ?string + { + $tagDescription = $tag->getDescription(); + $tagVariableName = $tag->getVariableName(); + $tagVariableType = $tag->getType(); + + // Skip if information we need is missing. + if (!$tagDescription || !$tagVariableName || !$tagVariableType) { + return null; + } + + $elements = $this->getElementsFromDescription($tagDescription, true); + + if ($elements === null) { + return null; + } + + $tagVariableType = $this->getTypeNameFromType($tagVariableType); + + if ($tagVariableType === null) { + return null; + } + + // It's common for an args parameter to accept a query var string or array with `string|array`. + // Remove the accepted string type for these so we get the strongest typing we can manage. + $tagVariableType = str_replace(['|string', 'string|'], '', $tagVariableType); + + return sprintf( + " * @phpstan-param %1\$s{\n * %2\$s,\n * } $%3\$s", + $tagVariableType, + implode(",\n * ", $elements), + $tagVariableName + ); + } + + private function getAdditionFromReturn(Return_ $tag): ?string + { + $tagDescription = $tag->getDescription(); + $tagVariableType = $tag->getType(); + + // Skip if information we need is missing. + if (!$tagDescription || !$tagVariableType) { + return null; + } + + $elements = $this->getElementsFromDescription($tagDescription, false); + + if ($elements === null) { + return null; + } + + $tagVariableType = $this->getTypeNameFromType($tagVariableType); + + if ($tagVariableType === null) { + return null; + } + + return sprintf( + " * @phpstan-return %1\$s{\n * %2\$s,\n * }", + $tagVariableType, + implode(",\n * ", $elements) + ); + } + + private function getTypeNameFromType(Type $tagVariableType): ?string + { + // PHPStan dosn't support typed array shapes (`int[]{...}`) so replace + // typed arrays such as `int[]` with `array`. + $tagVariableType = preg_replace('#[a-zA-Z0-9_]+\[\]#', 'array', $tagVariableType->__toString()); + + if ($tagVariableType === null) { + return null; + } + + if (strpos($tagVariableType, 'array') === false) { + // Skip if we have hash notation that's not for an array (ie. for `object`). + return null; + } + + if (strpos($tagVariableType, 'array|') !== false) { + // Move `array` to the end of union types so the appended array shape works. + $tagVariableType = str_replace('array|', '', $tagVariableType) . '|array'; + } + + return $tagVariableType; + } + + /** + * @return ?string[] + */ + private function getElementsFromDescription(Description $tagDescription, bool $optional): ?array + { + $text = $tagDescription->__toString(); + + // Skip if the description doesn't contain at least one correctly + // formatted `@type`, which indicates an array hash. + if (strpos($text, ' @type ') === false) { + return null; + } + + // Populate `$types` with the value of each top level `@type`. + $types = preg_split('/\R+ @type /', $text); + + if ($types === false) { + return null; + } + + unset($types[0]); + $elements = []; + + foreach ($types as $typeTag) { + $parts = preg_split('#\s+#', trim($typeTag)); + + if ($parts === false || count($parts) < 2) { + return null; + } + + list($type, $name) = $parts; + + // Bail out completely if any element doesn't have a static key. + if (strpos($name, '...$') !== false) { + return null; + } + + // Bail out completely if the name of any element is invalid. + if (strpos($name, '$') !== 0) { + return null; + } + + $elements[] = sprintf( + '%1$s%2$s: %3$s', + substr($name, 1), + $optional ? '?' : '', + $type + ); + } + + return $elements; + } +}; diff --git a/wordpress-stubs.php b/wordpress-stubs.php index fb14dc5..bc600bf 100644 --- a/wordpress-stubs.php +++ b/wordpress-stubs.php @@ -640,6 +640,14 @@ public function clear_destination($remote_destination) * } * * @return array|WP_Error The result (also stored in `WP_Upgrader::$result`), or a WP_Error on failure. + * @phpstan-param array{ + * source?: string, + * destination?: string, + * clear_destination?: bool, + * clear_working?: bool, + * abort_if_destination_exists?: bool, + * hook_extra?: array, + * } $args */ public function install_package($args = array()) { @@ -676,6 +684,15 @@ public function install_package($args = array()) * } * @return array|false|WP_Error The result from self::install_package() on success, otherwise a WP_Error, * or false if unable to connect to the filesystem. + * @phpstan-param array{ + * package?: string, + * destination?: string, + * clear_destination?: bool, + * clear_working?: bool, + * abort_if_destination_exists?: bool, + * is_multi?: bool, + * hook_extra?: array, + * } $options */ public function run($options) { @@ -769,6 +786,11 @@ public function upgrade_strings() * Default false. * } * @return string|false|WP_Error New WordPress version on success, false or WP_Error on failure. + * @phpstan-param array{ + * pre_check_md5?: bool, + * attempt_rollback?: bool, + * do_rollback?: bool, + * } $args */ public function upgrade($current, $args = array()) { @@ -1810,6 +1832,9 @@ public function upgrade($update = \false, $args = array()) * } * @return array|bool|WP_Error Will return an array of results, or true if there are no updates, * false or WP_Error for initial errors. + * @phpstan-param array{ + * clear_update_cache?: bool, + * } $args */ public function bulk_upgrade($language_updates = array(), $args = array()) { @@ -2857,6 +2882,9 @@ public function install_strings() * Default true. * } * @return bool|WP_Error True if the installation was successful, false or a WP_Error otherwise. + * @phpstan-param array{ + * clear_update_cache?: bool, + * } $args */ public function install($package, $args = array()) { @@ -2875,6 +2903,9 @@ public function install($package, $args = array()) * Default true. * } * @return bool|WP_Error True if the upgrade was successful, false or a WP_Error object otherwise. + * @phpstan-param array{ + * clear_update_cache?: bool, + * } $args */ public function upgrade($plugin, $args = array()) { @@ -2892,6 +2923,9 @@ public function upgrade($plugin, $args = array()) * @type bool $clear_update_cache Whether to clear the plugin updates cache if successful. Default true. * } * @return array|false An array of results indexed by plugin file, or false if unable to connect to the filesystem. + * @phpstan-param array{ + * clear_update_cache?: bool, + * } $args */ public function bulk_upgrade($plugins, $args = array()) { @@ -3206,6 +3240,9 @@ public function hide_activate_preview_actions($actions) * } * * @return bool|WP_Error True if the installation was successful, false or a WP_Error object otherwise. + * @phpstan-param array{ + * clear_update_cache?: bool, + * } $args */ public function install($package, $args = array()) { @@ -3224,6 +3261,9 @@ public function install($package, $args = array()) * Default true. * } * @return bool|WP_Error True if the upgrade was successful, false or a WP_Error object otherwise. + * @phpstan-param array{ + * clear_update_cache?: bool, + * } $args */ public function upgrade($theme, $args = array()) { @@ -3242,6 +3282,9 @@ public function upgrade($theme, $args = array()) * Default true. * } * @return array[]|false An array of results, or false if unable to connect to the filesystem. + * @phpstan-param array{ + * clear_update_cache?: bool, + * } $args */ public function bulk_upgrade($themes, $args = array()) { @@ -4030,6 +4073,12 @@ class WP_List_Table * screen. If left null, the current screen will be automatically set. * Default null. * } + * @phpstan-param array{ + * plural?: string, + * singular?: string, + * ajax?: bool, + * screen?: string, + * } $args */ public function __construct($args = array()) { @@ -5073,6 +5122,12 @@ class WP_Community_Events * symbol. e.g.: -122.341100. * @type string $country The ISO 3166-1 alpha-2 country code. e.g.: BR * } + * @phpstan-param false|array{ + * description?: string, + * latitude?: string, + * longitude?: string, + * country?: string, + * } $user_location */ public function __construct($user_id, $user_location = \false) { @@ -5898,6 +5953,18 @@ public function rmdir($path, $recursive = \false) * @type string $type Type of resource. 'f' for file, 'd' for directory. * @type mixed $files If a directory and $recursive is true, contains another array of files. * } + * @phpstan-return false|array{ + * name: string, + * perms: string, + * permsn: int, + * owner: string, + * size: int, + * lastmodunix: int, + * lastmod: mixed, + * time: int, + * type: string, + * files: mixed, + * } */ public function dirlist($path, $include_hidden = \true, $recursive = \false) { @@ -6267,6 +6334,18 @@ public function rmdir($path, $recursive = \false) * @type string $type Type of resource. 'f' for file, 'd' for directory. * @type mixed $files If a directory and $recursive is true, contains another array of files. * } + * @phpstan-return false|array{ + * name: string, + * perms: string, + * permsn: int, + * owner: string, + * size: int, + * lastmodunix: int, + * lastmod: mixed, + * time: int, + * type: string, + * files: mixed, + * } */ public function dirlist($path, $include_hidden = \true, $recursive = \false) { @@ -6629,6 +6708,18 @@ public function parselisting($line) * @type string $type Type of resource. 'f' for file, 'd' for directory. * @type mixed $files If a directory and $recursive is true, contains another array of files. * } + * @phpstan-return false|array{ + * name: string, + * perms: string, + * permsn: int, + * owner: string, + * size: int, + * lastmodunix: int, + * lastmod: mixed, + * time: int, + * type: string, + * files: mixed, + * } */ public function dirlist($path = '.', $include_hidden = \true, $recursive = \false) { @@ -6992,6 +7083,18 @@ public function rmdir($path, $recursive = \false) * @type string $type Type of resource. 'f' for file, 'd' for directory. * @type mixed $files If a directory and $recursive is true, contains another array of files. * } + * @phpstan-return false|array{ + * name: string, + * perms: string, + * permsn: int, + * owner: string, + * size: int, + * lastmodunix: int, + * lastmod: mixed, + * time: int, + * type: string, + * files: mixed, + * } */ public function dirlist($path = '.', $include_hidden = \true, $recursive = \false) { @@ -7440,6 +7543,18 @@ public function rmdir($path, $recursive = \false) * @type string $type Type of resource. 'f' for file, 'd' for directory. * @type mixed $files If a directory and $recursive is true, contains another array of files. * } + * @phpstan-return false|array{ + * name: string, + * perms: string, + * permsn: int, + * owner: string, + * size: int, + * lastmodunix: int, + * lastmod: mixed, + * time: int, + * type: string, + * files: mixed, + * } */ public function dirlist($path, $include_hidden = \true, $recursive = \false) { @@ -10239,6 +10354,13 @@ public function get_help_tab($id) * @type callable $callback Optional. A callback to generate the tab content. Default false. * @type int $priority Optional. The priority of the tab, used for ordering. Default 10. * } + * @phpstan-param array{ + * title?: string, + * id?: string, + * content?: string, + * callback?: callable, + * priority?: int, + * } $args */ public function add_help_tab($args) { @@ -10338,6 +10460,11 @@ public function get_screen_reader_text($key) * @type string $heading_list Screen reader text for the items list heading. * Default 'Items list'. * } + * @phpstan-param array{ + * heading_views?: string, + * heading_pagination?: string, + * heading_list?: string, + * } $content */ public function set_screen_reader_content($content = array()) { @@ -10380,6 +10507,9 @@ public function show_screen_options() * * @type bool $wrap Whether the screen-options-wrap div will be included. Defaults to true. * } + * @phpstan-param array{ + * wrap?: bool, + * } $options */ public function render_screen_options($options = array()) { @@ -29147,6 +29277,25 @@ class WP_Http * } * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. * A WP_Error instance upon error. + * @phpstan-param array{ + * method?: string, + * timeout?: float, + * redirection?: int, + * httpversion?: string, + * user-agent?: string, + * reject_unsafe_urls?: bool, + * blocking?: bool, + * headers?: string|array, + * cookies?: array, + * body?: string|array, + * compress?: bool, + * decompress?: bool, + * sslverify?: bool, + * sslcertificates?: string, + * stream?: bool, + * filename?: string, + * limit_response_size?: int, + * } $args */ public function request($url, $args = array()) { @@ -29281,6 +29430,10 @@ public function head($url, $args = array()) * @type string $headers HTTP response headers. * @type string $body HTTP response body. * } + * @phpstan-return array{ + * headers: string, + * body: string, + * } */ public static function processResponse($strResponse) { @@ -29307,6 +29460,11 @@ public static function processResponse($strResponse) * @type WP_Http_Cookie[] $cookies If the original headers contain the 'Set-Cookie' key, * an array containing `WP_Http_Cookie` objects is returned. * } + * @phpstan-return array{ + * response: array, + * newheaders: array, + * cookies: WP_Http_Cookie[], + * } */ public static function processHeaders($headers, $url = '') { @@ -30643,6 +30801,14 @@ public function remove_menu($id) * @type array $meta Meta data including the following keys: 'html', 'class', 'rel', 'lang', 'dir', * 'onclick', 'target', 'title', 'tabindex'. Default empty. * } + * @phpstan-param array{ + * id?: string, + * title?: string, + * parent?: string, + * href?: string, + * group?: bool, + * meta?: array, + * } $args */ public function add_node($args) { @@ -30696,6 +30862,11 @@ protected final function _get_nodes() * @type array $meta Meta data for the group including the following keys: * 'class', 'onclick', 'target', and 'title'. * } + * @phpstan-param array{ + * id?: string, + * parent?: string, + * meta?: array, + * } $args */ public final function add_group($args) { @@ -30829,6 +31000,15 @@ public function __construct($args = '') * element as CDATA. Default empty array. * } * @return string XML response. + * @phpstan-param array{ + * what?: string, + * action?: string|false, + * id?: int|WP_Error, + * old_id?: int|false, + * position?: string, + * data?: string|WP_Error, + * supplemental?: array, + * } $args */ public function add($args = '') { @@ -32301,6 +32481,28 @@ class WP_Block_Type * @type string|null $editor_style Block type editor style handle. * @type string|null $style Block type front end style handle. * } + * @phpstan-param array{ + * api_version?: string, + * title?: string, + * category?: string|null, + * parent?: array|null, + * icon?: string|null, + * description?: string, + * keywords?: array, + * textdomain?: string|null, + * styles?: array, + * variations?: array, + * supports?: array|null, + * example?: array|null, + * render_callback?: callable|null, + * attributes?: array|null, + * uses_context?: array, + * provides_context?: array|null, + * editor_script?: string|null, + * script?: string|null, + * editor_style?: string|null, + * style?: string|null, + * } $args */ public function __construct($block_type, $args = array()) { @@ -32724,6 +32926,53 @@ public function __call($name, $arguments) * @type bool $update_comment_post_cache Whether to prime the cache for comment posts. * Default false. * } + * @phpstan-param array{ + * author_email?: string, + * author_url?: string, + * author__in?: int[], + * author__not_in?: int[], + * comment__in?: int[], + * comment__not_in?: int[], + * count?: bool, + * date_query?: array, + * fields?: string, + * ID?: int, + * include_unapproved?: array, + * karma?: int, + * meta_key?: string, + * meta_value?: string, + * meta_query?: array, + * number?: int, + * paged?: int, + * offset?: int, + * no_found_rows?: bool, + * orderby?: string|array, + * order?: string, + * parent?: int, + * parent__in?: int[], + * parent__not_in?: int[], + * post_author__in?: int[], + * post_author__not_in?: int[], + * post_ID?: int, + * post_id?: int, + * post__in?: int[], + * post__not_in?: int[], + * post_author?: int, + * post_status?: string|array, + * post_type?: string, + * post_name?: string, + * post_parent?: int, + * search?: string, + * status?: string|array, + * type?: string|array, + * type__in?: string[], + * type__not_in?: string[], + * user_id?: int, + * hierarchical?: bool|string, + * cache_domain?: string, + * update_comment_meta_cache?: bool, + * update_comment_post_cache?: bool, + * } $query */ public function __construct($query = '') { @@ -33065,6 +33314,12 @@ public function to_array() * 'none' to disable `ORDER BY` clause. * } * @return WP_Comment[] Array of `WP_Comment` objects. + * @phpstan-param array{ + * format?: string, + * status?: string, + * hierarchical?: string, + * orderby?: string|array, + * } $args */ public function get_children($args = array()) { @@ -33321,6 +33576,24 @@ class WP_Customize_Control * 'date' are supported implicitly. Default 'text'. * @type callable $active_callback Active callback. * } + * @phpstan-param array{ + * instance_number?: int, + * manager?: WP_Customize_Manager, + * id?: string, + * settings?: array, + * setting?: string, + * capability?: string, + * priority?: int, + * section?: string, + * label?: string, + * description?: string, + * choices?: array, + * input_attrs?: array, + * allow_addition?: bool, + * json?: array, + * type?: string, + * active_callback?: callable, + * } $args */ public function __construct($manager, $id, $args = array()) { @@ -33734,6 +34007,14 @@ final class WP_Customize_Manager * @type bool $branching If changeset branching is allowed; otherwise, changesets are linear. Defaults to true. * @type bool $autosaved If data from a changeset's autosaved revision should be loaded if it exists. Defaults to false. * } + * @phpstan-param array{ + * changeset_uuid?: null|string|false, + * theme?: string, + * messenger_channel?: string, + * settings_previewed?: bool, + * branching?: bool, + * autosaved?: bool, + * } $args */ public function __construct($args = array()) { @@ -33994,6 +34275,12 @@ public function find_changeset_post_id($uuid) * @type bool $exclude_restore_dismissed Whether to exclude changeset auto-drafts that have been dismissed. Defaults to true. * } * @return WP_Post[] Auto-draft changesets. + * @phpstan-param array{ + * posts_per_page?: int, + * author?: int, + * post_status?: string, + * exclude_restore_dismissed?: bool, + * } $args */ protected function get_changeset_posts($args = array()) { @@ -34103,6 +34390,10 @@ public function _save_starter_content_changeset() * @type bool $exclude_post_data Whether the post input values should also be excluded. Defaults to false when lacking the customize capability. * } * @return array + * @phpstan-param array{ + * exclude_changeset?: bool, + * exclude_post_data?: bool, + * } $args */ public function unsanitized_post_values($args = array()) { @@ -34335,6 +34626,10 @@ public function current_theme($current_theme) * @type bool $validate_capability Whether the setting capability will be checked. * } * @return array Mapping of setting IDs to return value of validate method calls, either `true` or `WP_Error`. + * @phpstan-param array{ + * validate_existence?: bool, + * validate_capability?: bool, + * } $options */ public function validate_setting_values($setting_values, $options = array()) { @@ -34382,6 +34677,15 @@ public function save() * } * * @return array|WP_Error Returns array on success and WP_Error with array data on error. + * @phpstan-param array{ + * data?: array, + * status?: string, + * title?: string, + * date_gmt?: string, + * user_id?: int, + * starter_content?: bool, + * autosave?: bool, + * } $args */ function save_changeset_post($args = array()) { @@ -34997,6 +35301,11 @@ public function get_return_url() * @type string $section ID for section to be autofocused. * @type string $panel ID for panel to be autofocused. * } + * @phpstan-param array{ + * control?: string, + * section?: string, + * panel?: string, + * } $autofocus */ public function set_autofocus($autofocus) { @@ -35013,6 +35322,11 @@ public function set_autofocus($autofocus) * @type string $section ID for section to be autofocused. * @type string $panel ID for panel to be autofocused. * } + * @phpstan-return array{ + * control: string, + * section: string, + * panel: string, + * } */ public function get_autofocus() { @@ -35704,6 +36018,15 @@ class WP_Customize_Panel * @type string $type Type of the panel. * @type callable $active_callback Active callback. * } + * @phpstan-param array{ + * priority?: int, + * capability?: string, + * theme_supports?: string|string[], + * title?: string, + * description?: string, + * type?: string, + * active_callback?: callable, + * } $args */ public function __construct($manager, $id, $args = array()) { @@ -35984,6 +36307,17 @@ class WP_Customize_Section * instead of inline above the first control. * Default false. * } + * @phpstan-param array{ + * priority?: int, + * panel?: string, + * capability?: string, + * theme_supports?: string|string[], + * title?: string, + * description?: string, + * type?: string, + * active_callback?: callable, + * description_hidden?: bool, + * } $args */ public function __construct($manager, $id, $args = array()) { @@ -36246,6 +36580,17 @@ class WP_Customize_Setting * JSON serializable. * @type bool $dirty Whether or not the setting is initially dirty when created. * } + * @phpstan-param array{ + * type?: string, + * capability?: string, + * theme_supports?: string|string[], + * default?: string, + * transport?: string, + * validate_callback?: callable, + * sanitize_callback?: callable, + * sanitize_js_callback?: callable, + * dirty?: bool, + * } $args */ public function __construct($manager, $id, $args = array()) { @@ -36261,6 +36606,10 @@ public function __construct($manager, $id, $args = array()) * @type string $base ID base * @type array $keys Keys for multidimensional array. * } + * @phpstan-return array{ + * base: string, + * keys: array, + * } */ public final function id_data() { @@ -36979,6 +37328,10 @@ public function get_widget_control($args) * @type string $control Markup for widget control wrapping form. * @type string $content The contents of the widget form itself. * } + * @phpstan-return array{ + * control: string, + * content: string, + * } */ public function get_widget_control_parts($args) { @@ -37255,6 +37608,10 @@ public function selective_refresh_init() * @see WP_Customize_Nav_Menus::filter_wp_nav_menu_args() * * @return array Params. + * @phpstan-param array{ + * args?: array, + * widget_args?: array, + * } $params */ public function filter_dynamic_sidebar_params($params) { @@ -37369,6 +37726,10 @@ public function filter_sidebars_widgets_for_rendering_widget($sidebars_widgets) * @type int $sidebar_instance_number Disambiguating instance number. * } * @return string|false + * @phpstan-param array{ + * sidebar_id?: string, + * sidebar_instance_number?: int, + * } $context */ public function render_widget_partial($partial, $context) { @@ -37757,6 +38118,10 @@ public function get_sql() * @type string $join SQL fragment to append to the main JOIN clause. * @type string $where SQL fragment to append to the main WHERE clause. * } + * @phpstan-return array{ + * join: string, + * where: string, + * } */ protected function get_sql_clauses() { @@ -37778,6 +38143,10 @@ protected function get_sql_clauses() * @type string $join SQL fragment to append to the main JOIN clause. * @type string $where SQL fragment to append to the main WHERE clause. * } + * @phpstan-return array{ + * join: string, + * where: string, + * } */ protected function get_sql_for_query($query, $depth = 0) { @@ -37797,6 +38166,10 @@ protected function get_sql_for_query($query, $depth = 0) * @type string $join SQL fragment to append to the main JOIN clause. * @type string $where SQL fragment to append to the main WHERE clause. * } + * @phpstan-return array{ + * join: string, + * where: string, + * } */ protected function get_sql_for_subquery($query) { @@ -37814,6 +38187,10 @@ protected function get_sql_for_subquery($query) * @type string $join SQL fragment to append to the main JOIN clause. * @type string $where SQL fragment to append to the main WHERE clause. * } + * @phpstan-return array{ + * join: string, + * where: string, + * } */ protected function get_sql_for_clause($query, $parent_query) { @@ -38048,6 +38425,22 @@ private function __construct() * Quicktags using an array. Default true. * } * @return array Parsed arguments array. + * @phpstan-param array{ + * wpautop?: bool, + * media_buttons?: bool, + * default_editor?: string, + * drag_drop_upload?: bool, + * textarea_name?: string, + * textarea_rows?: int, + * tabindex?: string|int, + * tabfocus_elements?: string, + * editor_css?: string, + * editor_class?: string, + * teeny?: bool, + * dfw?: bool, + * tinymce?: bool|array, + * quicktags?: bool|array, + * } $settings */ public static function parse_settings($editor_id, $settings) { @@ -38321,6 +38714,10 @@ public function unregister_handler($id, $priority = 10) * } * @param string $url The URL attempting to be embedded. * @return string|false The embed HTML on success, false otherwise. + * @phpstan-param array{ + * width?: int, + * height?: int, + * } $attr */ public function get_embed_handler_html($attr, $url) { @@ -38341,6 +38738,10 @@ public function get_embed_handler_html($attr, $url) * @param string $url The URL attempting to be embedded. * @return string|false The embed HTML on success, otherwise the original URL. * `->maybe_make_link()` can return false on failure. + * @phpstan-param array{ + * width?: int, + * height?: int, + * } $attr */ public function shortcode($attr, $url = '') { @@ -39220,6 +39621,15 @@ class WP_Http_Cookie * } * @param string $requested_url The URL which the cookie was set on, used for default $domain * and $port values. + * @phpstan-param array{ + * name?: string, + * value?: mixed, + * expires?: string|int|null, + * path?: string, + * domain?: string, + * port?: int, + * host_only?: bool, + * } $data */ public function __construct($data, $requested_url = '') { @@ -39269,6 +39679,11 @@ public function getFullHeader() * @type string $path Cookie URL path. * @type string $domain Cookie domain. * } + * @phpstan-return array{ + * expires: string|int|null, + * path: string, + * domain: string, + * } */ public function get_attributes() { @@ -40192,6 +40607,9 @@ public abstract function resize($max_w, $max_h, $crop = \false); * } * } * @return array An array of resized images metadata by size. + * @phpstan-param array{ + * size?: array, + * } $sizes */ public abstract function multi_resize($sizes); /** @@ -40252,6 +40670,10 @@ public abstract function stream($mime_type = \null); * @type int $width The image width. * @type int $height The image height. * } + * @phpstan-return array{ + * width: int, + * height: int, + * } */ public function get_size() { @@ -40513,6 +40935,9 @@ protected function _resize($max_w, $max_h, $crop = \false) * } * } * @return array An array of resized images' metadata by size. + * @phpstan-param array{ + * size?: array, + * } $sizes */ public function multi_resize($sizes) { @@ -40531,6 +40956,11 @@ public function multi_resize($sizes) * } * @return array|WP_Error The image data array for inclusion in the `sizes` array in the image meta, * WP_Error object on error. + * @phpstan-param array{ + * width?: int, + * height?: int, + * crop?: bool, + * } $size_data */ public function make_subsize($size_data) { @@ -40767,6 +41197,9 @@ protected function thumbnail_image($dst_w, $dst_h, $filter_name = 'FILTER_TRIANG * } * } * @return array An array of resized images' metadata by size. + * @phpstan-param array{ + * size?: array, + * } $sizes */ public function multi_resize($sizes) { @@ -40785,6 +41218,11 @@ public function multi_resize($sizes) * } * @return array|WP_Error The image data array for inclusion in the `sizes` array in the image meta, * WP_Error object on error. + * @phpstan-param array{ + * width?: int, + * height?: int, + * crop?: bool, + * } $size_data */ public function make_subsize($size_data) { @@ -41707,6 +42145,10 @@ public function get_cast_for_type($type = '') * @type string $join SQL fragment to append to the main JOIN clause. * @type string $where SQL fragment to append to the main WHERE clause. * } + * @phpstan-return false|array{ + * join: string, + * where: string, + * } */ public function get_sql($type, $primary_table, $primary_id_column, $context = \null) { @@ -41725,6 +42167,10 @@ public function get_sql($type, $primary_table, $primary_id_column, $context = \n * @type string $join SQL fragment to append to the main JOIN clause. * @type string $where SQL fragment to append to the main WHERE clause. * } + * @phpstan-return array{ + * join: string, + * where: string, + * } */ protected function get_sql_clauses() { @@ -41746,6 +42192,10 @@ protected function get_sql_clauses() * @type string $join SQL fragment to append to the main JOIN clause. * @type string $where SQL fragment to append to the main WHERE clause. * } + * @phpstan-return array{ + * join: string, + * where: string, + * } */ protected function get_sql_for_query(&$query, $depth = 0) { @@ -41769,6 +42219,10 @@ protected function get_sql_for_query(&$query, $depth = 0) * @type string $join SQL fragment to append to the main JOIN clause. * @type string $where SQL fragment to append to the main WHERE clause. * } + * @phpstan-return array{ + * join: string, + * where: string, + * } */ public function get_sql_for_clause(&$clause, $parent_query, $clause_key = '') { @@ -42027,6 +42481,25 @@ class WP_Network_Query * @type string $search Search term(s) to retrieve matching networks for. Default empty. * @type bool $update_network_cache Whether to prime the cache for found networks. Default true. * } + * @phpstan-param array{ + * network__in?: int[], + * network__not_in?: int[], + * count?: bool, + * fields?: string, + * number?: int, + * offset?: int, + * no_found_rows?: bool, + * orderby?: string|array, + * order?: string, + * domain?: string, + * domain__in?: string[], + * domain__not_in?: string[], + * path?: string, + * path__in?: string[], + * path__not_in?: string[], + * search?: string, + * update_network_cache?: bool, + * } $query */ public function __construct($query = '') { @@ -42777,6 +43250,9 @@ public function __call($name, $arguments) * is not found in the built-in providers list. Default true. * } * @return string|false The oEmbed provider URL on success, false on failure. + * @phpstan-param array{ + * discover?: bool, + * } $args */ public function get_provider($url, $args = '') { @@ -42997,6 +43473,12 @@ public function __construct($extension_type) * @type string $message The error message. * } * @return bool True on success, false on failure. + * @phpstan-param array{ + * type?: string, + * file?: string, + * line?: string, + * message?: string, + * } $error */ public function set($extension, $error) { @@ -44375,6 +44857,80 @@ public function fill_query_vars($array) * @type int $w The week number of the year. Default empty. Accepts numbers 0-53. * @type int $year The four-digit year. Default empty. Accepts any four-digit year. * } + * @phpstan-param array{ + * attachment_id?: int, + * author?: int|string, + * author_name?: string, + * author__in?: int[], + * author__not_in?: int[], + * cache_results?: bool, + * cat?: int|string, + * category__and?: int[], + * category__in?: int[], + * category__not_in?: int[], + * category_name?: string, + * comment_count?: array|int, + * comment_status?: string, + * comments_per_page?: int, + * date_query?: array, + * day?: int, + * exact?: bool, + * fields?: string, + * hour?: int, + * ignore_sticky_posts?: int|bool, + * m?: int, + * meta_compare?: string, + * meta_compare_key?: string, + * meta_key?: string, + * meta_query?: array, + * meta_value?: string, + * meta_value_num?: int, + * meta_type_key?: string, + * menu_order?: int, + * monthnum?: int, + * name?: string, + * nopaging?: bool, + * no_found_rows?: bool, + * offset?: int, + * order?: string, + * orderby?: string|array, + * p?: int, + * page?: int, + * paged?: int, + * page_id?: int, + * pagename?: string, + * perm?: string, + * ping_status?: string, + * post__in?: int[], + * post__not_in?: int[], + * post_mime_type?: string, + * post_name__in?: string[], + * post_parent?: int, + * post_parent__in?: int[], + * post_parent__not_in?: int[], + * post_type?: string|array, + * post_status?: string|array, + * posts_per_page?: int, + * posts_per_archive_page?: int, + * s?: string, + * second?: int, + * sentence?: bool, + * suppress_filters?: bool, + * tag?: string, + * tag__and?: int[], + * tag__in?: int[], + * tag__not_in?: int[], + * tag_id?: int, + * tag_slug__and?: string[], + * tag_slug__in?: string[], + * tax_query?: array, + * title?: string, + * update_post_meta_cache?: bool, + * update_post_term_cache?: bool, + * lazy_load_term_meta?: bool, + * w?: int, + * year?: int, + * } $query */ public function parse_query($query = '') { @@ -45326,6 +45882,10 @@ public function __construct(\WP_Recovery_Mode_Link_Service $link_service) * @type string $type The extension type. Either 'plugin' or 'theme'. * } * @return true|WP_Error True if email sent, WP_Error otherwise. + * @phpstan-param array{ + * slug?: string, + * type?: string, + * } $extension */ public function maybe_send_recovery_mode_email($rate_limit, $error, $extension) { @@ -45774,6 +46334,10 @@ protected function get_link_ttl() * @type string $slug The extension slug. This is the plugin or theme's directory. * @type string $type The extension type. Either 'plugin' or 'theme'. * } + * @phpstan-return false|array{ + * slug: string, + * type: string, + * } */ protected function get_extension_for_error($error) { @@ -46616,6 +47180,15 @@ public function add_endpoint($name, $places, $query_var = \true) * and rewrite rules built for each in-turn. Default true. * @type bool $endpoints Whether endpoints should be applied to the generated rules. Default true. * } + * @phpstan-param array{ + * with_front?: bool, + * ep_mask?: int, + * paged?: bool, + * feed?: bool, + * forcomments?: bool, + * walk_dirs?: bool, + * endpoints?: bool, + * } $args */ public function add_permastruct($name, $struct, $args = array()) { @@ -47476,6 +48049,45 @@ class WP_Site_Query * comparisons. Default empty. * @type string $meta_compare Comparison operator to test the `$meta_value`. Default empty. * } + * @phpstan-param array{ + * site__in?: int[], + * site__not_in?: int[], + * count?: bool, + * date_query?: array, + * fields?: string, + * ID?: int, + * number?: int, + * offset?: int, + * no_found_rows?: bool, + * orderby?: string|array, + * order?: string, + * network_id?: int, + * network__in?: int[], + * network__not_in?: int[], + * domain?: string, + * domain__in?: string[], + * domain__not_in?: string[], + * path?: string, + * path__in?: string[], + * path__not_in?: string[], + * public?: int, + * archived?: int, + * mature?: int, + * spam?: int, + * deleted?: int, + * lang_id?: int, + * lang__in?: string[], + * lang__not_in?: string[], + * search?: string, + * search_columns?: string[], + * update_site_cache?: bool, + * update_site_meta_cache?: bool, + * meta_query?: array, + * meta_key?: string, + * meta_value?: string, + * meta_type?: string, + * meta_compare?: string, + * } $query */ public function __construct($query = '') { @@ -47962,6 +48574,10 @@ protected static function is_first_order_clause($query) * @type string $join SQL fragment to append to the main JOIN clause. * @type string $where SQL fragment to append to the main WHERE clause. * } + * @phpstan-return array{ + * join: string, + * where: string, + * } */ public function get_sql($primary_table, $primary_id_column) { @@ -47980,6 +48596,10 @@ public function get_sql($primary_table, $primary_id_column) * @type string $join SQL fragment to append to the main JOIN clause. * @type string $where SQL fragment to append to the main WHERE clause. * } + * @phpstan-return array{ + * join: string, + * where: string, + * } */ protected function get_sql_clauses() { @@ -48001,6 +48621,10 @@ protected function get_sql_clauses() * @type string $join SQL fragment to append to the main JOIN clause. * @type string $where SQL fragment to append to the main WHERE clause. * } + * @phpstan-return array{ + * join: string, + * where: string, + * } */ protected function get_sql_for_query(&$query, $depth = 0) { @@ -48020,6 +48644,10 @@ protected function get_sql_for_query(&$query, $depth = 0) * @type string $join SQL fragment to append to the main JOIN clause. * @type string $where SQL fragment to append to the main WHERE clause. * } + * @phpstan-return array{ + * join: string, + * where: string, + * } */ public function get_sql_for_clause(&$clause, $parent_query) { @@ -48552,6 +49180,39 @@ class WP_Term_Query * comparisons. Default empty. * @type string $meta_compare Comparison operator to test the 'meta_value'. Default empty. * } + * @phpstan-param array{ + * taxonomy?: string|array, + * object_ids?: int|int[], + * orderby?: string, + * order?: string, + * hide_empty?: bool|int, + * include?: int[]|string, + * exclude?: int[]|string, + * exclude_tree?: int[]|string, + * number?: int|string, + * offset?: int, + * fields?: string, + * count?: bool, + * name?: string|array, + * slug?: string|array, + * term_taxonomy_id?: int|int[], + * hierarchical?: bool, + * search?: string, + * name__like?: string, + * description__like?: string, + * pad_counts?: bool, + * get?: string, + * child_of?: int, + * parent?: int|string, + * childless?: bool, + * cache_domain?: string, + * update_term_meta_cache?: bool, + * meta_query?: array, + * meta_key?: string, + * meta_value?: string, + * meta_type?: string, + * meta_compare?: string, + * } $query */ public function __construct($query = '') { @@ -49057,6 +49718,12 @@ public function _changed($orig, $final) * of `$orig`. A value >= 0 corresponds to index of `$final`. * Value < 0 indicates a blank row. * } + * @phpstan-return array{ + * orig_matches: array, + * final_matches: array, + * orig_rows: array, + * final_rows: array, + * } */ public function interleave_changed_lines($orig, $final) { @@ -50821,6 +51488,34 @@ public static function fill_query_vars($args) * @type string[] $login__not_in An array of logins to exclude. Users matching one of these * logins will not be included in results. Default empty array. * } + * @phpstan-param array{ + * blog_id?: int, + * role?: string|array, + * role__in?: string[], + * role__not_in?: string[], + * meta_key?: string, + * meta_value?: string, + * meta_compare?: string, + * include?: int[], + * exclude?: int[], + * search?: string, + * search_columns?: string[], + * orderby?: string|array, + * order?: string, + * offset?: int, + * number?: int, + * paged?: int, + * count_total?: bool, + * fields?: string|array, + * who?: string, + * has_published_posts?: bool|array, + * nicename?: string, + * nicename__in?: string[], + * nicename__not_in?: string[], + * login?: string, + * login__in?: string[], + * login__not_in?: string[], + * } $query */ public function prepare_query($query = array()) { @@ -51914,6 +52609,9 @@ public function is_preview() * * @type int $number Number increment used for multiples of the same widget. * } + * @phpstan-param int|array{ + * number?: int, + * } $widget_args */ public function display_callback($args, $widget_args = 1) { @@ -51942,6 +52640,9 @@ public function update_callback($deprecated = 1) * @type int $number Number increment used for multiples of the same widget. * } * @return string|null + * @phpstan-param int|array{ + * number?: int, + * } $widget_args */ public function form_callback($widget_args = 1) { @@ -52095,6 +52796,10 @@ public function sayHello() * @type int $number2 A second number to add. * } * @return int Sum of the two given numbers. + * @phpstan-param array{ + * number1?: int, + * number2?: int, + * } $args */ public function addTwoNumbers($args) { @@ -52223,6 +52928,10 @@ public function initialise_blog_option_info() * - 'blogid' * - 'blogName' * - 'xmlrpc' - url of xmlrpc endpoint + * @phpstan-param array{ + * username?: string, + * password?: string, + * } $args */ public function wp_getUsersBlogs($args) { @@ -52384,6 +53093,12 @@ protected function _prepare_user($user, $fields) * } * } * @return int|IXR_Error Post ID on success, IXR_Error instance otherwise. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * content_struct?: array, + * } $args */ public function wp_newPost($args) { @@ -52444,6 +53159,13 @@ protected function _insert_post($user, $content_struct) * @type array $content_struct Extra content arguments. * } * @return true|IXR_Error True on success, IXR_Error on failure. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * post_id?: int, + * content_struct?: array, + * } $args */ public function wp_editPost($args) { @@ -52464,6 +53186,12 @@ public function wp_editPost($args) * @type int $post_id Post ID. * } * @return true|IXR_Error True on success, IXR_Error instance on failure. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * post_id?: int, + * } $args */ public function wp_deletePost($args) { @@ -52516,6 +53244,13 @@ public function wp_deletePost($args) * - 'categories' * - 'tags' * - 'enclosure' + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * post_id?: int, + * fields?: array, + * } $args */ public function wp_getPost($args) { @@ -52541,6 +53276,13 @@ public function wp_getPost($args) * @type array $fields Optional. The subset of post type fields to return in the response array. * } * @return array|IXR_Error Array contains a collection of posts. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * filter?: array, + * fields?: array, + * } $args */ public function wp_getPosts($args) { @@ -52563,6 +53305,12 @@ public function wp_getPosts($args) * 'parent', 'description', and 'slug'. * } * @return int|IXR_Error The term ID on success, or an IXR_Error object on failure. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * content_struct?: array, + * } $args */ public function wp_newTerm($args) { @@ -52586,6 +53334,13 @@ public function wp_newTerm($args) * 'description', and 'slug'. * } * @return true|IXR_Error True on success, IXR_Error instance on failure. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * term_id?: int, + * content_struct?: array, + * } $args */ public function wp_editTerm($args) { @@ -52607,6 +53362,13 @@ public function wp_editTerm($args) * @type int $term_id Term ID. * } * @return true|IXR_Error True on success, IXR_Error instance on failure. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * taxnomy_name?: string, + * term_id?: int, + * } $args */ public function wp_deleteTerm($args) { @@ -52637,6 +53399,13 @@ public function wp_deleteTerm($args) * - 'description' * - 'parent' * - 'count' + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * taxnomy?: string, + * term_id?: string, + * } $args */ public function wp_getTerm($args) { @@ -52662,6 +53431,13 @@ public function wp_getTerm($args) * 'offset', 'orderby', 'order', 'hide_empty', and 'search'. Default empty array. * } * @return array|IXR_Error An associative array of terms data on success, IXR_Error instance otherwise. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * taxnomy?: string, + * filter?: array, + * } $args */ public function wp_getTerms($args) { @@ -52685,6 +53461,13 @@ public function wp_getTerms($args) * Default empty array. * } * @return array|IXR_Error An array of taxonomy data on success, IXR_Error instance otherwise. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * taxnomy?: string, + * fields?: array, + * } $args */ public function wp_getTaxonomy($args) { @@ -52707,6 +53490,13 @@ public function wp_getTaxonomy($args) * } * @return array|IXR_Error An associative array of taxonomy data with returned fields determined * by `$fields`, or an IXR_Error instance on failure. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * filter?: array, + * fields?: array, + * } $args */ public function wp_getTaxonomies($args) { @@ -52746,6 +53536,13 @@ public function wp_getTaxonomies($args) * - 'url' * - 'display_name' * - 'roles' + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * user_id?: int, + * fields?: array, + * } $args */ public function wp_getUser($args) { @@ -52773,6 +53570,13 @@ public function wp_getUser($args) * @type array $fields (optional) * } * @return array|IXR_Error users data + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * filter?: array, + * fields?: array, + * } $args */ public function wp_getUsers($args) { @@ -52791,6 +53595,12 @@ public function wp_getUsers($args) * @type array $fields (optional) * } * @return array|IXR_Error (@see wp_getUser) + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * fields?: array, + * } $args */ public function wp_getProfile($args) { @@ -52816,6 +53626,12 @@ public function wp_getProfile($args) * - 'bio' * } * @return true|IXR_Error True, on success. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * content_struct?: array, + * } $args */ public function wp_editProfile($args) { @@ -52834,6 +53650,12 @@ public function wp_editProfile($args) * @type string $password * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * page_id?: int, + * username?: string, + * password?: string, + * } $args */ public function wp_getPage($args) { @@ -52852,6 +53674,12 @@ public function wp_getPage($args) * @type int $num_pages * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * num_pages?: int, + * } $args */ public function wp_getPages($args) { @@ -52872,6 +53700,12 @@ public function wp_getPages($args) * @type array $content_struct * } * @return int|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * content_struct?: array, + * } $args */ public function wp_newPage($args) { @@ -52890,6 +53724,12 @@ public function wp_newPage($args) * @type int $page_id * } * @return true|IXR_Error True, if success. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * page_id?: int, + * } $args */ public function wp_deletePage($args) { @@ -52910,6 +53750,14 @@ public function wp_deletePage($args) * @type string $publish * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * page_id?: int, + * username?: string, + * password?: string, + * content?: string, + * publish?: string, + * } $args */ public function wp_editPage($args) { @@ -52929,6 +53777,11 @@ public function wp_editPage($args) * @type string $password * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * } $args */ public function wp_getPageList($args) { @@ -52946,6 +53799,11 @@ public function wp_getPageList($args) * @type string $password * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * } $args */ public function wp_getAuthors($args) { @@ -52963,6 +53821,11 @@ public function wp_getAuthors($args) * @type string $password * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * } $args */ public function wp_getTags($args) { @@ -52981,6 +53844,12 @@ public function wp_getTags($args) * @type array $category * } * @return int|IXR_Error Category ID. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * category?: array, + * } $args */ public function wp_newCategory($args) { @@ -52999,6 +53868,12 @@ public function wp_newCategory($args) * @type int $category_id * } * @return bool|IXR_Error See wp_delete_term() for return info. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * category_id?: int, + * } $args */ public function wp_deleteCategory($args) { @@ -53018,6 +53893,13 @@ public function wp_deleteCategory($args) * @type int $max_results * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * category?: array, + * max_results?: int, + * } $args */ public function wp_suggestCategories($args) { @@ -53036,6 +53918,12 @@ public function wp_suggestCategories($args) * @type int $comment_id * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * comment_id?: int, + * } $args */ public function wp_getComment($args) { @@ -53065,6 +53953,12 @@ public function wp_getComment($args) * @type array $struct * } * @return array|IXR_Error Contains a collection of comments. See wp_xmlrpc_server::wp_getComment() for a description of each item contents + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * struct?: array, + * } $args */ public function wp_getComments($args) { @@ -53086,6 +53980,12 @@ public function wp_getComments($args) * @type int $comment_ID * } * @return bool|IXR_Error See wp_delete_comment(). + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * comment_ID?: int, + * } $args */ public function wp_deleteComment($args) { @@ -53116,6 +54016,13 @@ public function wp_deleteComment($args) * @type array $content_struct * } * @return true|IXR_Error True, on success. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * comment_ID?: int, + * content_struct?: array, + * } $args */ public function wp_editComment($args) { @@ -53135,6 +54042,13 @@ public function wp_editComment($args) * @type array $content_struct * } * @return int|IXR_Error See wp_new_comment(). + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * post?: string|int, + * content_struct?: array, + * } $args */ public function wp_newComment($args) { @@ -53152,6 +54066,11 @@ public function wp_newComment($args) * @type string $password * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * } $args */ public function wp_getCommentStatusList($args) { @@ -53170,6 +54089,12 @@ public function wp_getCommentStatusList($args) * @type int $post_id * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * post_id?: int, + * } $args */ public function wp_getCommentCount($args) { @@ -53187,6 +54112,11 @@ public function wp_getCommentCount($args) * @type string $password * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * } $args */ public function wp_getPostStatusList($args) { @@ -53204,6 +54134,11 @@ public function wp_getPostStatusList($args) * @type string $password * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * } $args */ public function wp_getPageStatusList($args) { @@ -53221,6 +54156,11 @@ public function wp_getPageStatusList($args) * @type string $password * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * } $args */ public function wp_getPageTemplates($args) { @@ -53239,6 +54179,12 @@ public function wp_getPageTemplates($args) * @type array $options * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * options?: array, + * } $args */ public function wp_getOptions($args) { @@ -53268,6 +54214,12 @@ public function _getOptions($options) * @type array $options * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * options?: array, + * } $args */ public function wp_setOptions($args) { @@ -53294,6 +54246,12 @@ public function wp_setOptions($args) * - 'caption' * - 'description' * - 'metadata' + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * attachment_id?: int, + * } $args */ public function wp_getMediaItem($args) { @@ -53323,6 +54281,12 @@ public function wp_getMediaItem($args) * @type array $struct * } * @return array|IXR_Error Contains a collection of media items. See wp_xmlrpc_server::wp_getMediaItem() for a description of each item contents + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * struct?: array, + * } $args */ public function wp_getMediaLibrary($args) { @@ -53340,6 +54304,11 @@ public function wp_getMediaLibrary($args) * @type string $password * } * @return array|IXR_Error List of post formats, otherwise IXR_Error object. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * } $args */ public function wp_getPostFormats($args) { @@ -53370,6 +54339,13 @@ public function wp_getPostFormats($args) * - 'menu_position' * - 'taxonomies' * - 'supports' + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * post_type_name?: string, + * fields?: array, + * } $args */ public function wp_getPostType($args) { @@ -53391,6 +54367,13 @@ public function wp_getPostType($args) * @type array $fields (optional) * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * filter?: array, + * fields?: array, + * } $args */ public function wp_getPostTypes($args) { @@ -53416,6 +54399,13 @@ public function wp_getPostTypes($args) * @type array $fields (optional) * } * @return array|IXR_Error contains a collection of posts. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * post_id?: int, + * fields?: array, + * } $args */ public function wp_getRevisions($args) { @@ -53436,6 +54426,12 @@ public function wp_getRevisions($args) * @type int $revision_id * } * @return bool|IXR_Error false if there was an error restoring, true if success. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * revision_id?: int, + * } $args */ public function wp_restoreRevision($args) { @@ -53459,6 +54455,11 @@ public function wp_restoreRevision($args) * @type string $password * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * } $args */ public function blogger_getUsersBlogs($args) { @@ -53475,6 +54476,10 @@ public function blogger_getUsersBlogs($args) * @type string $password Password. * } * @return array|IXR_Error + * @phpstan-param array{ + * username?: string, + * password?: string, + * } $args */ protected function _multisite_getUsersBlogs($args) { @@ -53494,6 +54499,11 @@ protected function _multisite_getUsersBlogs($args) * @type string $password * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * } $args */ public function blogger_getUserInfo($args) { @@ -53512,6 +54522,12 @@ public function blogger_getUserInfo($args) * @type string $password * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * post_ID?: int, + * username?: string, + * password?: string, + * } $args */ public function blogger_getPost($args) { @@ -53531,6 +54547,13 @@ public function blogger_getPost($args) * @type int $numberposts (optional) * } * @return array|IXR_Error + * @phpstan-param array{ + * appkey?: string, + * blog_id?: int, + * username?: string, + * password?: string, + * numberposts?: int, + * } $args */ public function blogger_getRecentPosts($args) { @@ -53575,6 +54598,14 @@ public function blogger_setTemplate($args) * @type string $publish * } * @return int|IXR_Error + * @phpstan-param array{ + * appkey?: string, + * blog_id?: int, + * username?: string, + * password?: string, + * content?: string, + * publish?: string, + * } $args */ public function blogger_newPost($args) { @@ -53595,6 +54626,14 @@ public function blogger_newPost($args) * @type bool $publish * } * @return true|IXR_Error true when done. + * @phpstan-param array{ + * blog_id?: int, + * post_ID?: int, + * username?: string, + * password?: string, + * content?: string, + * publish?: bool, + * } $args */ public function blogger_editPost($args) { @@ -53613,6 +54652,12 @@ public function blogger_editPost($args) * @type string $password * } * @return true|IXR_Error True when post is deleted. + * @phpstan-param array{ + * blog_id?: int, + * post_ID?: int, + * username?: string, + * password?: string, + * } $args */ public function blogger_deletePost($args) { @@ -53658,6 +54703,13 @@ public function blogger_deletePost($args) * @type int $publish * } * @return int|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * content_struct?: array, + * publish?: int, + * } $args */ public function mw_newPost($args) { @@ -53701,6 +54753,13 @@ public function attach_uploads($post_ID, $post_content) * @type int $publish * } * @return true|IXR_Error True on success. + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * content_struct?: array, + * publish?: int, + * } $args */ public function mw_editPost($args) { @@ -53719,6 +54778,12 @@ public function mw_editPost($args) * @type string $password * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * post_ID?: int, + * username?: string, + * password?: string, + * } $args */ public function mw_getPost($args) { @@ -53737,6 +54802,12 @@ public function mw_getPost($args) * @type int $numberposts * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * numberposts?: int, + * } $args */ public function mw_getRecentPosts($args) { @@ -53754,6 +54825,11 @@ public function mw_getRecentPosts($args) * @type string $password * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * } $args */ public function mw_getCategories($args) { @@ -53778,6 +54854,12 @@ public function mw_getCategories($args) * @type array $data * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * data?: array, + * } $args */ public function mw_newMediaObject($args) { @@ -53800,6 +54882,12 @@ public function mw_newMediaObject($args) * @type int $numberposts * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * numberposts?: int, + * } $args */ public function mt_getRecentPostTitles($args) { @@ -53817,6 +54905,11 @@ public function mt_getRecentPostTitles($args) * @type string $password * } * @return array|IXR_Error + * @phpstan-param array{ + * blog_id?: int, + * username?: string, + * password?: string, + * } $args */ public function mt_getCategoryList($args) { @@ -53834,6 +54927,11 @@ public function mt_getCategoryList($args) * @type string $password * } * @return array|IXR_Error + * @phpstan-param array{ + * post_ID?: int, + * username?: string, + * password?: string, + * } $args */ public function mt_getPostCategories($args) { @@ -53852,6 +54950,12 @@ public function mt_getPostCategories($args) * @type array $categories * } * @return true|IXR_Error True on success. + * @phpstan-param array{ + * post_ID?: int, + * username?: string, + * password?: string, + * categories?: array, + * } $args */ public function mt_setPostCategories($args) { @@ -53900,6 +55004,11 @@ public function mt_getTrackbackPings($post_ID) * @type string $password * } * @return int|IXR_Error + * @phpstan-param array{ + * post_ID?: int, + * username?: string, + * password?: string, + * } $args */ public function mt_publishPost($args) { @@ -53920,6 +55029,10 @@ public function mt_publishPost($args) * @type string $pagelinkedto * } * @return string|IXR_Error + * @phpstan-param array{ + * pagelinkedfrom?: string, + * pagelinkedto?: string, + * } $args */ public function pingback_ping($args) { @@ -56853,6 +57966,12 @@ public function sanitize($value) * @type bool $auto_add Whether pages will auto_add to this menu. Default false. * } * @return null|void + * @phpstan-param false|array{ + * name?: string, + * description?: string, + * parent?: int, + * auto_add?: bool, + * } $value */ protected function update($value) { @@ -57176,6 +58295,16 @@ class WP_Customize_Partial * A partial render is considered a failure if the render_callback returns * false. * } + * @phpstan-param array{ + * type?: string, + * selector?: string, + * settings?: string[], + * primary_setting?: string, + * capability?: string, + * render_callback?: callable, + * container_inclusive?: bool, + * fallback_refresh?: bool, + * } $args */ public function __construct(\WP_Customize_Selective_Refresh $component, $id, $args = array()) { @@ -57191,6 +58320,10 @@ public function __construct(\WP_Customize_Selective_Refresh $component, $id, $ar * @type string $base ID base. * @type array $keys Keys for multidimensional array. * } + * @phpstan-return array{ + * base: string, + * keys: array, + * } */ public final function id_data() { @@ -59754,6 +60887,10 @@ public function serve_request($path = \null) * @type array $_links Links. * @type array $_embedded Embedded objects. * } + * @phpstan-return array{ + * _links: array, + * _embedded: array, + * } */ public function response_to_data($response, $embed) { @@ -59800,6 +60937,10 @@ public static function get_compact_response_links($response) * @type array $_links Links. * @type array $_embedded Embedded objects. * } + * @phpstan-return array{ + * _links: array, + * _embedded: array, + * } */ protected function embed_links($data, $embed = \true) { @@ -59944,6 +61085,9 @@ protected function get_json_last_error() * @type string $context Context. * } * @return WP_REST_Response The API root index data. + * @phpstan-param array{ + * context?: string, + * } $request */ public function get_index($request) { @@ -68318,6 +69462,11 @@ public function _register_one($number = -1) * @type bool $legacy Whether widget is in legacy mode. * } * @return bool Whether Text widget instance contains legacy data. + * @phpstan-param array{ + * text?: string, + * filter?: bool|string, + * legacy?: bool, + * } $instance */ public function is_legacy_instance($instance) { @@ -68974,6 +70123,10 @@ public function init_charset() * @type string $charset Character set. * @type string $collate Collation. * } + * @phpstan-return array{ + * charset: string, + * collate: string, + * } */ public function determine_charset($charset, $collate) { @@ -70991,6 +72144,22 @@ function get_link_to_edit($link) * } * @param bool $wp_error Optional. Whether to return a WP_Error object on failure. Default false. * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success. + * @phpstan-param array{ + * link_id?: int, + * link_url?: string, + * link_name?: string, + * link_image?: string, + * link_target?: string, + * link_description?: string, + * link_visible?: string, + * link_owner?: int, + * link_rating?: int, + * link_updated?: string, + * link_rel?: string, + * link_notes?: string, + * link_rss?: string, + * link_category?: int, + * } $linkdata */ function wp_insert_link($linkdata, $wp_error = \false) { @@ -71421,6 +72590,13 @@ function wp_dashboard_site_activity() * @type string $id The container id. * } * @return bool False if no posts were found. True otherwise. + * @phpstan-param array{ + * max?: int, + * status?: string, + * order?: string, + * title?: string, + * id?: string, + * } $args */ function wp_dashboard_recent_posts($args) { @@ -72492,6 +73668,14 @@ function _wp_privacy_requests_screen_options() * 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', or * 'trash'. Default false (all statuses except 'auto-draft'). * } + * @phpstan-param array{ + * content?: string, + * author?: string, + * category?: string, + * start_date?: string, + * end_date?: string, + * status?: string, + * } $args */ function export_wp($args = array()) { @@ -72587,6 +73771,13 @@ function wp_print_file_editor_templates() * @type string $nonce Nonce. * } * @return true|WP_Error True on success or `WP_Error` on failure. + * @phpstan-param array{ + * file?: string, + * plugin?: string, + * theme?: string, + * newcontent?: string, + * nonce?: string, + * } $args */ function wp_edit_theme_plugin_file($args) { @@ -72656,6 +73847,15 @@ function validate_file_to_edit($file, $allowed_files = array()) * @return string[] On success, returns an associative array of file attributes. * On failure, returns `$overrides['upload_error_handler']( &$file, $message )` * or `array( 'error' => $message )`. + * @phpstan-param false|array{ + * upload_error_handler?: callable, + * unique_filename_callback?: callable, + * upload_error_strings?: string[], + * test_form?: bool, + * test_size?: bool, + * test_type?: bool, + * mimes?: string[], + * } $overrides */ function _wp_handle_upload(&$file, $overrides, $time, $action) { @@ -74109,6 +75309,12 @@ function sort_menu($a, $b) * @type callable $callback Meta box display callback. * @type array $args Extra meta box arguments. * } + * @phpstan-param array{ + * id?: string, + * title?: string, + * callback?: callable, + * args?: array, + * } $args */ function post_submit_meta_box($post, $args = array()) { @@ -74137,6 +75343,12 @@ function attachment_submit_meta_box($post) * @type callable $callback Meta box display callback. * @type array $args Extra meta box arguments. * } + * @phpstan-param array{ + * id?: string, + * title?: string, + * callback?: callable, + * args?: array, + * } $box */ function post_format_meta_box($post, $box) { @@ -74161,6 +75373,12 @@ function post_format_meta_box($post, $box) * @type string $taxonomy Taxonomy. Default 'post_tag'. * } * } + * @phpstan-param array{ + * id?: string, + * title?: string, + * callback?: callable, + * args?: array, + * } $box */ function post_tags_meta_box($post, $box) { @@ -74185,6 +75403,12 @@ function post_tags_meta_box($post, $box) * @type string $taxonomy Taxonomy. Default 'category'. * } * } + * @phpstan-param array{ + * id?: string, + * title?: string, + * callback?: callable, + * args?: array, + * } $box */ function post_categories_meta_box($post, $box) { @@ -75164,6 +76388,11 @@ function network_settings_add_js() * @type array $links The tabs to include with (label|url|cap) keys. * @type string $selected The ID of the selected link. * } + * @phpstan-param array{ + * blog_id?: int, + * links?: array, + * selected?: string, + * } $args */ function network_edit_site_nav($args = array()) { @@ -75275,6 +76504,12 @@ function wp_nav_menu_item_link_meta_box() * @type callable $callback Meta box display callback. * @type WP_Post_Type $args Extra meta box arguments (the post type object for this meta box). * } + * @phpstan-param array{ + * id?: string, + * title?: string, + * callback?: callable, + * args?: WP_Post_Type, + * } $box */ function wp_nav_menu_item_post_type_meta_box($object, $box) { @@ -75295,6 +76530,12 @@ function wp_nav_menu_item_post_type_meta_box($object, $box) * @type callable $callback Meta box display callback. * @type object $args Extra meta box arguments (the taxonomy object for this meta box). * } + * @phpstan-param array{ + * id?: string, + * title?: string, + * callback?: callable, + * args?: object, + * } $box */ function wp_nav_menu_item_taxonomy_meta_box($object, $box) { @@ -75594,6 +76835,21 @@ function options_reading_blog_charset() * @return object|array|WP_Error Response object or array on success, WP_Error on failure. See the * {@link https://developer.wordpress.org/reference/functions/plugins_api/ function reference article} * for more information on the make-up of possible return values depending on the value of `$action`. + * @phpstan-param object|array{ + * slug?: string, + * per_page?: int, + * page?: int, + * number?: int, + * search?: string, + * tag?: string, + * author?: string, + * user?: string, + * browse?: string, + * locale?: string, + * installed_plugins?: string, + * is_ssl?: bool, + * fields?: array, + * } $args */ function plugins_api($action, $args = array()) { @@ -75667,6 +76923,12 @@ function display_plugins_table() * @type string $version The most recent version of the plugin. * @type string $file Plugin filename relative to the plugins directory. * } + * @phpstan-return array{ + * status: string, + * url: string, + * version: string, + * file: string, + * } */ function install_plugin_install_status($api, $loop = \false) { @@ -75747,6 +77009,20 @@ function install_plugin_information() * @type string $RequiresPHP Minimum required version of PHP. * @type string $UpdateURI ID of the plugin for update purposes, should be a URI. * } + * @phpstan-return array{ + * Name: string, + * Title: string, + * Description: string, + * Author: string, + * AuthorURI: string, + * Version: string, + * TextDomain: string, + * DomainPath: string, + * Network: bool, + * RequiresWP: string, + * RequiresPHP: string, + * UpdateURI: string, + * } */ function get_plugin_data($plugin_file, $markup = \true, $translate = \true) { @@ -75778,6 +77054,17 @@ function get_plugin_data($plugin_file, $markup = \true, $translate = \true) * @type string $DomainPath Plugins relative directory path to .mo files. * @type bool $Network Whether the plugin can only be activated network-wide. * } + * @phpstan-return array{ + * Name: string, + * Title: string, + * Description: string, + * Author: string, + * AuthorURI: string, + * Version: string, + * TextDomain: string, + * DomainPath: string, + * Network: bool, + * } */ function _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup = \true, $translate = \true) { @@ -77003,6 +78290,10 @@ function postbox_classes($box_id, $screen_id) * @type string $0 The permalink with placeholder for the post name. * @type string $1 The post name. * } + * @phpstan-return array{ + * 0: string, + * 1: string, + * } */ function get_sample_permalink($id, $title = \null, $name = \null) { @@ -77261,6 +78552,10 @@ function _wp_personal_data_cleanup_requests() * @param string $group_id The group identifier. * @param int $groups_count The number of all groups * @return string The HTML for this group and its items. + * @phpstan-param array{ + * group_label?: string, + * items?: array, + * } $group_data */ function wp_privacy_generate_personal_data_export_group_html($group_data, $group_id = '', $groups_count = 1) { @@ -77696,6 +78991,14 @@ function wp_create_categories($categories, $post_id = '') * @param bool $wp_error Optional. Default false. * @return int|object The ID number of the new or updated Category on success. Zero or a WP_Error on failure, * depending on param $wp_error. + * @phpstan-param array{ + * cat_ID?: int, + * taxonomy?: string, + * cat_name?: string, + * category_description?: string, + * category_nicename?: string, + * category_parent?: int|string, + * } $catarr */ function wp_insert_category($catarr, $wp_error = \false) { @@ -77826,6 +79129,15 @@ function wp_category_checklist($post_id = 0, $descendants_and_self = 0, $selecte * of echoing it. Default true. * } * @return string HTML list of input elements. + * @phpstan-param array{ + * descendants_and_self?: int, + * selected_cats?: int[], + * popular_cats?: int[], + * walker?: Walker, + * taxonomy?: string, + * checked_ontop?: bool, + * echo?: bool, + * } $args */ function wp_terms_checklist($post_id = 0, $args = array()) { @@ -78041,6 +79353,12 @@ function add_meta_box($id, $title, $callback, $screen = \null, $context = 'advan * @type callable $old_callback The original callback for this meta box. * @type array $args Extra meta box arguments. * } + * @phpstan-param array{ + * id?: string, + * title?: string, + * old_callback?: callable, + * args?: array, + * } $box */ function do_block_editor_incompatible_meta_box($object, $box) { @@ -78177,6 +79495,10 @@ function add_settings_section($id, $title, $callback, $page) * @type string $class CSS Class to be added to the `