diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 8c498f1121e8a..6db93188dda4b 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -59,7 +59,6 @@ includes: - tests/phpstan/baselines/offsetAccess.nonOffsetAccessible.neon - tests/phpstan/baselines/offsetAccess.notFound.neon - tests/phpstan/baselines/offsetAssign.valueType.neon - - tests/phpstan/baselines/parameter.defaultValue.neon - tests/phpstan/baselines/parameter.notFound.neon - tests/phpstan/baselines/parameterByRef.type.neon - tests/phpstan/baselines/parameterByRef.unusedType.neon diff --git a/src/wp-admin/includes/bookmark.php b/src/wp-admin/includes/bookmark.php index aae87b9abc60f..efa5bea9bf5c8 100644 --- a/src/wp-admin/includes/bookmark.php +++ b/src/wp-admin/includes/bookmark.php @@ -12,6 +12,8 @@ * @since 2.0.0 * * @return int The link ID on success. The value 0 on failure. + * + * @phpstan-return int<0, max> */ function add_link() { return edit_link(); @@ -24,6 +26,8 @@ function add_link() { * * @param int $link_id Optional. ID of the link to edit. Default 0. * @return int The link ID on success. The value 0 on failure. + * + * @phpstan-return int<0, max> */ function edit_link( $link_id = 0 ) { if ( ! current_user_can( 'manage_links' ) ) { @@ -56,6 +60,9 @@ function edit_link( $link_id = 0 ) { * @since 2.0.0 * * @return stdClass Default link object. + * + * @phpstan-impure + * @phpstan-return object{link_url: string, link_name: string, link_visible: 'Y'}&stdClass */ function get_default_link_to_edit() { $link = new stdClass(); @@ -122,6 +129,8 @@ function wp_delete_link( $link_id ) { * * @param int $link_id Link ID to look up. * @return int[]|WP_Error The IDs of the requested link's categories, or else a WP_Error if the `link_category` taxonomy was unregistered. + * + * @phpstan-return array>|WP_Error */ function wp_get_link_cats( $link_id = 0 ) { $cats = wp_get_object_terms( $link_id, 'link_category', array( 'fields' => 'ids' ) ); @@ -301,6 +310,8 @@ function wp_set_link_cats( $link_id = 0, $link_categories = array() ) { * * @param array $linkdata Link data to update. See wp_insert_link() for accepted arguments. * @return int The updated link ID on success. The value 0 on failure. + * + * @phpstan-return int<0, max> */ function wp_update_link( $linkdata ) { $link_id = (int) $linkdata['link_id']; diff --git a/src/wp-admin/includes/class-custom-background.php b/src/wp-admin/includes/class-custom-background.php index 7f8f23485086a..7e318658da48b 100644 --- a/src/wp-admin/includes/class-custom-background.php +++ b/src/wp-admin/includes/class-custom-background.php @@ -19,6 +19,8 @@ class Custom_Background { * * @since 3.0.0 * @var callable + * + * @phpstan-var ''|callable(): void */ public $admin_header_callback; @@ -27,6 +29,8 @@ class Custom_Background { * * @since 3.0.0 * @var callable + * + * @phpstan-var ''|callable(): void */ public $admin_image_div_callback; @@ -47,6 +51,9 @@ class Custom_Background { * Default empty string. * @param callable $admin_image_div_callback Optional. Custom image div output callback. * Default empty string. + * + * @phpstan-param ''|callable(): void $admin_header_callback + * @phpstan-param ''|callable(): void $admin_image_div_callback */ public function __construct( $admin_header_callback = '', $admin_image_div_callback = '' ) { $this->admin_header_callback = $admin_header_callback; diff --git a/src/wp-admin/includes/class-custom-image-header.php b/src/wp-admin/includes/class-custom-image-header.php index 367ba04cdc340..14c8434362676 100644 --- a/src/wp-admin/includes/class-custom-image-header.php +++ b/src/wp-admin/includes/class-custom-image-header.php @@ -19,6 +19,8 @@ class Custom_Image_Header { * * @since 2.1.0 * @var callable + * + * @phpstan-var ''|callable(): void */ public $admin_header_callback; @@ -27,6 +29,8 @@ class Custom_Image_Header { * * @since 3.0.0 * @var callable + * + * @phpstan-var ''|callable(): void */ public $admin_image_div_callback; @@ -54,6 +58,8 @@ class Custom_Image_Header { * @param callable $admin_header_callback Administration header callback. * @param callable $admin_image_div_callback Optional. Custom image div output callback. * Default empty string. + * + * @phpstan-param ''|callable(): void $admin_image_div_callback */ public function __construct( $admin_header_callback, $admin_image_div_callback = '' ) { $this->admin_header_callback = $admin_header_callback; @@ -310,6 +316,8 @@ public function process_default_headers() { * * @param string $type The header type. One of 'default' (for the Uploaded Images control) * or 'uploaded' (for the Uploaded Images control). + * + * @phpstan-param 'default'|'uploaded' $type */ public function show_header_selector( $type = 'default' ) { if ( 'default' === $type ) { @@ -1169,6 +1177,13 @@ public function filter_upload_tabs( $tabs ) { * registered for that theme; and the key of an image uploaded for that theme * (the attachment ID of the image). Or an array of arguments: attachment_id, * url, width, height. All are required. + * + * @phpstan-param string|array{ + * attachment_id: int<1, max>, + * url: string, + * width: int<0, max>, + * height: int<0, max>, + * } $choice */ final public function set_header_image( $choice ) { if ( is_array( $choice ) || is_object( $choice ) ) { diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index 2b927a7f81a6a..7294f89d1bd3b 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -62,6 +62,8 @@ public function __construct( $args = array() ) { * @param string $name Comment author name. * @param int $comment_id Comment ID. * @return string Avatar with the user name. + * + * @phpstan-return non-falsy-string */ public function floated_admin_avatar( $name, $comment_id ) { $comment = get_comment( $comment_id ); diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php index 2792b4b3ec3d0..623ee0fbb6d6b 100644 --- a/src/wp-admin/includes/class-wp-list-table.php +++ b/src/wp-admin/includes/class-wp-list-table.php @@ -319,6 +319,9 @@ public function prepare_items() { * @since 3.1.0 * * @param array|string $args Array or string of arguments with information about the pagination. + * + * @phpstan-param array{total_items?: int, total_pages?: int, per_page?: int} $args + * @phpstan-return void */ protected function set_pagination_args( $args ) { $args = wp_parse_args( diff --git a/src/wp-admin/includes/image.php b/src/wp-admin/includes/image.php index 935c613d561e9..c3a4a8d769be0 100644 --- a/src/wp-admin/includes/image.php +++ b/src/wp-admin/includes/image.php @@ -635,7 +635,7 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) { break; } $basename = str_replace( '.', '-', wp_basename( $file ) ) . '-image' . $ext; - $uploaded = wp_upload_bits( $basename, '', $metadata['image']['data'] ); + $uploaded = wp_upload_bits( $basename, null, $metadata['image']['data'] ); if ( false === $uploaded['error'] ) { $image_attachment = array( 'post_mime_type' => $metadata['image']['mime'], diff --git a/src/wp-admin/includes/list-table.php b/src/wp-admin/includes/list-table.php index 565144768e7bb..442fea665fd6f 100644 --- a/src/wp-admin/includes/list-table.php +++ b/src/wp-admin/includes/list-table.php @@ -36,6 +36,7 @@ * * @phpstan-template T of WP_List_Table * @phpstan-param class-string $class_name + * @phpstan-param array{screen?: string|WP_Screen|null} $args * @phpstan-return T|false */ function _get_list_table( $class_name, $args = array() ) { diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php index 6134db45b6a95..ed04f5c0e7a00 100644 --- a/src/wp-admin/includes/media.php +++ b/src/wp-admin/includes/media.php @@ -1237,6 +1237,8 @@ function image_align_input_fields( $post, $checked = '' ) { * @param WP_Post $post * @param bool|string $check * @return array An array of data for the image size input fields. + * + * @phpstan-return array{label: string, input: 'html', html: string} */ function image_size_input_fields( $post, $check = '' ) { /** @@ -1315,6 +1317,8 @@ function image_size_input_fields( $post, $check = '' ) { * @param WP_Post $post * @param string $url_type * @return string HTML markup for the link URL buttons. + * + * @phpstan-return non-falsy-string */ function image_link_input_fields( $post, $url_type = '' ) { @@ -1348,6 +1352,8 @@ function image_link_input_fields( $post, $url_type = '' ) { * * @param WP_Post $edit_post Attachment WP_Post object. * @return string HTML markup for the textarea element. + * + * @phpstan-return non-falsy-string */ function wp_caption_input_textarea( $edit_post ) { // Post data is already escaped. @@ -1637,6 +1643,8 @@ function get_media_items( $post_id, $errors ) { * @param int $attachment_id Attachment ID for modification. * @param string|array $args Optional. Override defaults. * @return string HTML form for attachment. + * + * @phpstan-return non-falsy-string */ function get_media_item( $attachment_id, $args = null ) { global $redir_tab; @@ -1931,6 +1939,8 @@ function get_media_item( $attachment_id, $args = null ) { * @param int $attachment_id * @param array $args * @return array An array containing the media item and its metadata. + * + * @phpstan-return array{item: string, meta: string} */ function get_compat_media_markup( $attachment_id, $args = null ) { $post = get_post( $attachment_id ); @@ -3013,6 +3023,8 @@ function media_upload_library_form( $errors ) { * * @param string $default_view * @return string HTML content of the form. + * + * @phpstan-return non-falsy-string */ function wp_media_insert_url_form( $default_view = 'image' ) { /** This filter is documented in wp-admin/includes/media.php */ diff --git a/src/wp-admin/includes/menu.php b/src/wp-admin/includes/menu.php index f1c2985e93e8e..1e71c782ec8ea 100644 --- a/src/wp-admin/includes/menu.php +++ b/src/wp-admin/includes/menu.php @@ -211,6 +211,7 @@ * * @phpstan-template T of string * @phpstan-param T $class_to_add + * @phpstan-pure * @phpstan-return ( $classes is empty ? T : non-empty-string ) */ function add_cssclass( $class_to_add, $classes ) { diff --git a/src/wp-admin/includes/meta-boxes.php b/src/wp-admin/includes/meta-boxes.php index 535a00cd3fe94..9149f50daadd8 100644 --- a/src/wp-admin/includes/meta-boxes.php +++ b/src/wp-admin/includes/meta-boxes.php @@ -1257,6 +1257,8 @@ function link_target_meta_box( $link ) { * if it matches the current link's relationship. * Default empty string. * @param mixed $deprecated Deprecated. Not used. + * + * @phpstan-param '' $deprecated */ function xfn_check( $xfn_relationship, $xfn_value = '', $deprecated = '' ) { global $link; diff --git a/src/wp-admin/includes/ms.php b/src/wp-admin/includes/ms.php index 155170aaf4f41..211a3c2bbddff 100644 --- a/src/wp-admin/includes/ms.php +++ b/src/wp-admin/includes/ms.php @@ -1187,6 +1187,8 @@ function network_edit_site_nav( $args = array() ) { * @since 4.9.0 * * @return array Help tab arguments. + * + * @phpstan-return array{id: 'overview', title: string, content: non-falsy-string} */ function get_site_screen_help_tab_args() { return array( @@ -1211,6 +1213,8 @@ function get_site_screen_help_tab_args() { * @since 4.9.0 * * @return string Help sidebar content. + * + * @phpstan-return non-falsy-string */ function get_site_screen_help_sidebar_content() { return '

' . __( 'For more information:' ) . '

' . diff --git a/src/wp-admin/includes/nav-menu.php b/src/wp-admin/includes/nav-menu.php index f26d63d528e78..7eb8763b86cbe 100644 --- a/src/wp-admin/includes/nav-menu.php +++ b/src/wp-admin/includes/nav-menu.php @@ -1348,6 +1348,16 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) { * @since 3.0.0 * * @return string[] Array of column titles keyed by their column name. + * + * @phpstan-return array{ + * _title: string, + * cb: '', + * link-target: string, + * title-attribute: string, + * css-classes: string, + * xfn: string, + * description: string, + * } */ function wp_nav_menu_manage_columns() { return array( diff --git a/src/wp-admin/includes/plugin-install.php b/src/wp-admin/includes/plugin-install.php index b37b956d3455c..ffae71c5b81f6 100644 --- a/src/wp-admin/includes/plugin-install.php +++ b/src/wp-admin/includes/plugin-install.php @@ -309,6 +309,8 @@ function install_dashboard() { * @since 4.6.0 The `$type_selector` parameter was deprecated. * * @param bool $deprecated Not used. + * + * @phpstan-param true $deprecated */ function install_search_form( $deprecated = true ) { $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term'; diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php index a34d473bca650..fddc9163b23cf 100644 --- a/src/wp-admin/includes/plugin.php +++ b/src/wp-admin/includes/plugin.php @@ -907,6 +907,7 @@ function activate_plugins( $plugins, $redirect = '', $network_wide = false, $sil * @return bool|null|WP_Error True on success, false if `$plugins` is empty, `WP_Error` on failure. * `null` if filesystem credentials are required to proceed. * + * @phpstan-param '' $deprecated * @phpstan-return ( $plugins is empty ? false : true|null|WP_Error ) */ function delete_plugins( $plugins, $deprecated = '' ) { @@ -1398,6 +1399,8 @@ function uninstall_plugin( $plugin ) { * * Pass 'none' to leave div.wp-menu-image empty so an icon can be added via CSS. * @param int|float $position Optional. The position in the menu order this item should appear. * @return string The resulting page's hook_suffix. + * + * @phpstan-param ''|callable $callback */ function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $icon_url = '', $position = null ) { global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages; @@ -1493,6 +1496,8 @@ function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $call * @param callable $callback Optional. The function to be called to output the content for this page. * @param int|float $position Optional. The position in the menu order this item should appear. * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. + * + * @phpstan-param ''|callable $callback */ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { global $submenu, $menu, $_wp_real_parent_file, $_wp_submenu_nopriv, @@ -1606,6 +1611,8 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, * @param callable $callback Optional. The function to be called to output the content for this page. * @param int $position Optional. The position in the menu order this item should appear. * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. + * + * @phpstan-param ''|callable $callback */ function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); @@ -1630,6 +1637,8 @@ function add_management_page( $page_title, $menu_title, $capability, $menu_slug, * @param callable $callback Optional. The function to be called to output the content for this page. * @param int $position Optional. The position in the menu order this item should appear. * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. + * + * @phpstan-param ''|callable $callback */ function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); @@ -1654,6 +1663,8 @@ function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $c * @param callable $callback Optional. The function to be called to output the content for this page. * @param int $position Optional. The position in the menu order this item should appear. * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. + * + * @phpstan-param ''|callable $callback */ function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); @@ -1678,6 +1689,8 @@ function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $cal * @param callable $callback Optional. The function to be called to output the content for this page. * @param int $position Optional. The position in the menu order this item should appear. * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. + * + * @phpstan-param ''|callable $callback */ function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); @@ -1702,6 +1715,8 @@ function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $c * @param callable $callback Optional. The function to be called to output the content for this page. * @param int $position Optional. The position in the menu order this item should appear. * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. + * + * @phpstan-param ''|callable $callback */ function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { if ( current_user_can( 'edit_users' ) ) { @@ -1731,6 +1746,8 @@ function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $cal * @param callable $callback Optional. The function to be called to output the content for this page. * @param int $position Optional. The position in the menu order this item should appear. * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. + * + * @phpstan-param ''|callable $callback */ function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); @@ -1755,6 +1772,8 @@ function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, * @param callable $callback Optional. The function to be called to output the content for this page. * @param int $position Optional. The position in the menu order this item should appear. * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. + * + * @phpstan-param ''|callable $callback */ function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); @@ -1779,6 +1798,8 @@ function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $cal * @param callable $callback Optional. The function to be called to output the content for this page. * @param int $position Optional. The position in the menu order this item should appear. * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. + * + * @phpstan-param ''|callable $callback */ function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); @@ -1803,6 +1824,8 @@ function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $cal * @param callable $callback Optional. The function to be called to output the content for this page. * @param int $position Optional. The position in the menu order this item should appear. * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. + * + * @phpstan-param ''|callable $callback */ function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); @@ -1827,6 +1850,8 @@ function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $cal * @param callable $callback Optional. The function to be called to output the content for this page. * @param int $position Optional. The position in the menu order this item should appear. * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. + * + * @phpstan-param ''|callable $callback */ function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); @@ -1851,6 +1876,8 @@ function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $cal * @param callable $callback Optional. The function to be called to output the content for this page. * @param int $position Optional. The position in the menu order this item should appear. * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. + * + * @phpstan-param ''|callable $callback */ function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); @@ -2146,6 +2173,8 @@ function get_plugin_page_hook( $plugin_page, $parent_page ) { * @param string $parent_page The slug name for the parent menu (or the file name of a standard * WordPress admin page). * @return string Hook name for the plugin page. + * + * @phpstan-return non-falsy-string */ function get_plugin_page_hookname( $plugin_page, $parent_page ) { global $admin_page_hooks; diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php index c39135316978f..e33659f37bc5e 100644 --- a/src/wp-admin/includes/post.php +++ b/src/wp-admin/includes/post.php @@ -1220,6 +1220,8 @@ function _fix_attachment_links( $post ) { * * @param string $type The post_type you want the statuses for. Default 'post'. * @return string[] An array of all the statuses for the supplied post type. + * + * @phpstan-return list */ function get_available_post_statuses( $type = 'post' ) { $statuses = wp_count_posts( $type ); diff --git a/src/wp-admin/includes/taxonomy.php b/src/wp-admin/includes/taxonomy.php index dbdab1af4fab8..5673fb9635499 100644 --- a/src/wp-admin/includes/taxonomy.php +++ b/src/wp-admin/includes/taxonomy.php @@ -188,6 +188,8 @@ function wp_insert_category( $catarr, $wp_error = false ) { * * @param array $catarr The 'cat_ID' value is required. All other keys are optional. * @return int|false The ID number of the new or updated Category on success. Zero or FALSE on failure. + * + * @phpstan-return int<0, max>|false */ function wp_update_category( $catarr ) { $cat_id = (int) $catarr['cat_ID']; diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php index 93428dcc4ae6d..32f763ad48710 100644 --- a/src/wp-admin/includes/template.php +++ b/src/wp-admin/includes/template.php @@ -1302,6 +1302,8 @@ function _get_plugin_from_callback( $callback ) { * Often this is the object that's the focus of the current screen, * for example a `WP_Post` or `WP_Comment` object. * @return int Number of meta_boxes. + * + * @phpstan-return int<0, max> */ function do_meta_boxes( $screen, $context, $data_object ) { global $wp_meta_boxes; @@ -1708,6 +1710,8 @@ function add_settings_section( $id, $title, $callback, $page, $args = array() ) * @type string $class CSS Class to be added to the `` element when the * field is output. * } + * + * @phpstan-return void */ function add_settings_field( $id, $title, $callback, $page, $section = 'default', $args = array() ) { global $wp_settings_fields; @@ -2143,6 +2147,8 @@ function _admin_search_query() { * * @param string $title Optional. Title of the Iframe page. Default empty. * @param bool $deprecated Not used. + * + * @phpstan-param false $deprecated */ function iframe_header( $title = '', $deprecated = false ) { global $hook_suffix, $admin_body_class, $body_id, $wp_locale; @@ -2652,6 +2658,8 @@ function submit_button( $text = '', $type = 'primary', $name = 'submit', $wrap = * e.g. `id="search-submit"`, though the array format is generally preferred. * Default empty string. * @return string Submit button HTML. + * + * @phpstan-return non-falsy-string */ function get_submit_button( $text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '' ) { if ( ! is_array( $type ) ) { diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php index 244401cf24013..461ab78a219e5 100644 --- a/src/wp-admin/includes/upgrade.php +++ b/src/wp-admin/includes/upgrade.php @@ -43,6 +43,8 @@ * @type string $password The password of the site owner, if their user account didn't already exist. * @type string $password_message The explanatory message regarding the password. * } + * + * @phpstan-param '' $deprecated */ function wp_install( $blog_title, @@ -1865,7 +1867,7 @@ function upgrade_340() { if ( 'yes' === $wpdb->get_var( "SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'" ) ) { $uninstall_plugins = get_option( 'uninstall_plugins' ); delete_option( 'uninstall_plugins' ); - add_option( 'uninstall_plugins', $uninstall_plugins, null, false ); + add_option( 'uninstall_plugins', $uninstall_plugins, '', false ); } } } diff --git a/src/wp-admin/includes/widgets.php b/src/wp-admin/includes/widgets.php index e751602866b0d..5697a6e9ff0dd 100644 --- a/src/wp-admin/includes/widgets.php +++ b/src/wp-admin/includes/widgets.php @@ -322,6 +322,8 @@ function wp_widget_control( $sidebar_args ) { /** * @param string $classes * @return string Modified body classes. + * + * @phpstan-return non-falsy-string */ function wp_widgets_access_body_class( $classes ) { return "$classes widgets_access "; diff --git a/src/wp-admin/update.php b/src/wp-admin/update.php index a6c59ec06dab2..a0ba9cfc069b2 100644 --- a/src/wp-admin/update.php +++ b/src/wp-admin/update.php @@ -87,7 +87,7 @@ wp_redirect( admin_url( 'update.php?action=activate-plugin&success=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce'] ) ); die(); } - iframe_header( __( 'Plugin Reactivation' ), true ); + iframe_header( __( 'Plugin Reactivation' ) ); if ( isset( $_GET['success'] ) ) { echo '

' . __( 'Plugin reactivated successfully.' ) . '

'; } diff --git a/src/wp-includes/abilities-api.php b/src/wp-includes/abilities-api.php index 393e40b56ed8c..66dd394809a23 100644 --- a/src/wp-includes/abilities-api.php +++ b/src/wp-includes/abilities-api.php @@ -292,6 +292,8 @@ * of ability behavior. * } * @return WP_Ability|null The registered ability instance on success, `null` on failure. + * + * @phpstan-param lowercase-string&non-falsy-string $name */ function wp_register_ability( string $name, array $args ): ?WP_Ability { if ( ! doing_action( 'wp_abilities_api_init' ) ) { diff --git a/src/wp-includes/author-template.php b/src/wp-includes/author-template.php index 342132feadd85..204f69cac580a 100644 --- a/src/wp-includes/author-template.php +++ b/src/wp-includes/author-template.php @@ -20,6 +20,8 @@ * * @param string $deprecated Deprecated. * @return string The author's display name, empty string if unknown. + * + * @phpstan-param '' $deprecated */ function get_the_author( $deprecated = '' ) { global $authordata; @@ -57,6 +59,9 @@ function get_the_author( $deprecated = '' ) { * @param string $deprecated Deprecated. * @param bool $deprecated_echo Deprecated. Use get_the_author(). Echo the string or return it. * @return string The author's display name, from get_the_author(). + * + * @phpstan-param '' $deprecated + * @phpstan-param true $deprecated_echo */ function the_author( $deprecated = '', $deprecated_echo = true ) { if ( ! empty( $deprecated ) ) { @@ -362,6 +367,8 @@ function get_the_author_posts_link() { * @since 4.4.0 Converted into a wrapper for get_the_author_posts_link() * * @param string $deprecated Unused. + * + * @phpstan-param '' $deprecated */ function the_author_posts_link( $deprecated = '' ) { if ( ! empty( $deprecated ) ) { diff --git a/src/wp-includes/block-patterns.php b/src/wp-includes/block-patterns.php index 50ca1a426378d..3e50b349d242c 100644 --- a/src/wp-includes/block-patterns.php +++ b/src/wp-includes/block-patterns.php @@ -277,6 +277,8 @@ function wp_normalize_remote_block_pattern( $pattern ) { * @since 6.3.0 Add 'pattern-directory/core' to the pattern's 'source'. * * @param WP_Screen $deprecated Unused. Formerly the screen that the current request was triggered from. + * + * @phpstan-param null $deprecated */ function _load_remote_block_patterns( $deprecated = null ) { if ( ! empty( $deprecated ) ) { diff --git a/src/wp-includes/block-supports/elements.php b/src/wp-includes/block-supports/elements.php index fe9543a5d5474..e8076cc1bd3ba 100644 --- a/src/wp-includes/block-supports/elements.php +++ b/src/wp-includes/block-supports/elements.php @@ -13,6 +13,8 @@ * @access private * * @return string The unique class name. + * + * @phpstan-return lowercase-string&non-falsy-string */ function wp_get_elements_class_name(): string { return wp_unique_prefixed_id( 'wp-elements-' ); diff --git a/src/wp-includes/block-supports/typography.php b/src/wp-includes/block-supports/typography.php index 8e80d0e60bf9d..9ecc1b6edd5a2 100644 --- a/src/wp-includes/block-supports/typography.php +++ b/src/wp-includes/block-supports/typography.php @@ -560,6 +560,8 @@ function wp_get_computed_fluid_typography_value( $args = array() ) { * @param bool|array $settings Optional Theme JSON settings array that overrides any global theme settings. * Default is false. * @return string|null Font-size value or null if a size is not passed in $preset. + * + * @phpstan-param array $settings */ function wp_get_typography_font_size_value( $preset, $settings = array() ) { if ( ! isset( $preset['size'] ) ) { diff --git a/src/wp-includes/block-template-utils.php b/src/wp-includes/block-template-utils.php index 78cd1bbdc15f5..5f829e3eabab5 100644 --- a/src/wp-includes/block-template-utils.php +++ b/src/wp-includes/block-template-utils.php @@ -1491,6 +1491,8 @@ function wp_is_theme_directory_ignored( $path ) { * @since 6.0.0 Adds the whole theme to the export archive. * * @return WP_Error|string Path of the ZIP file or error on failure. + * + * @phpstan-return non-falsy-string|WP_Error */ function wp_generate_block_templates_export_file() { $wp_version = wp_get_wp_version(); @@ -1711,6 +1713,8 @@ function get_template_hierarchy( $slug, $is_custom = false, $template_prefix = ' * prepared for inserting or updating the database. * @param WP_REST_Request $deprecated Deprecated. Not used. * @return stdClass|WP_Error The updated object representing a template or template part. + * + * @phpstan-param null $deprecated */ function inject_ignored_hooked_blocks_metadata_attributes( $changes, $deprecated = null ) { if ( null !== $deprecated ) { diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index beaf08d4022c6..e8e137b21108d 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -3084,6 +3084,8 @@ static function ( $format ) { * @param WP_Block $block Block instance. * @param bool $is_next Flag for handling `next/previous` blocks. * @return string|null The pagination arrow HTML or null if there is none. + * + * @phpstan-return non-falsy-string|null */ function get_query_pagination_arrow( $block, $is_next ) { $arrow_map = array( @@ -3184,6 +3186,8 @@ function build_comment_query_vars_from_block( $block ) { * @param string $pagination_type Optional. Type of the arrow we will be rendering. * Accepts 'next' or 'previous'. Default 'next'. * @return string|null The pagination arrow HTML or null if there is none. + * + * @phpstan-return non-falsy-string|null */ function get_comments_pagination_arrow( $block, $pagination_type = 'next' ) { $arrow_map = array( diff --git a/src/wp-includes/bookmark.php b/src/wp-includes/bookmark.php index e1c8a6e522a00..c9a9d2ae825dd 100644 --- a/src/wp-includes/bookmark.php +++ b/src/wp-includes/bookmark.php @@ -81,6 +81,9 @@ function get_bookmark( $bookmark, $output = OBJECT, $filter = 'raw' ) { * @param int $bookmark The bookmark ID to get field. * @param string $context Optional. The context of how the field will be used. Default 'display'. * @return string|WP_Error + * + * @phpstan-param 'link_id'|'link_url'|'link_name'|'link_image'|'link_target'|'link_description'|'link_visible'|'link_owner'|'link_rating'|'link_updated'|'link_rel'|'link_notes'|'link_rss'|'link_category' $field + * @phpstan-return array>|int|string */ function get_bookmark_field( $field, $bookmark, $context = 'display' ) { $bookmark = (int) $bookmark; @@ -403,6 +406,9 @@ function sanitize_bookmark( $bookmark, $context = 'display' ) { * @param string $context How to filter the field value. Accepts 'raw', 'edit', 'db', * 'display', 'attribute', or 'js'. Default 'display'. * @return mixed The filtered value. + * + * @phpstan-param 'link_id'|'link_url'|'link_name'|'link_image'|'link_target'|'link_description'|'link_visible'|'link_owner'|'link_rating'|'link_updated'|'link_rel'|'link_notes'|'link_rss'|'link_category' $field + * @phpstan-return array|int|string */ function sanitize_bookmark_field( $field, $value, $bookmark_id, $context ) { $int_fields = array( 'link_id', 'link_rating' ); diff --git a/src/wp-includes/category-template.php b/src/wp-includes/category-template.php index 1d456f309de3d..b4c40d2ac971f 100644 --- a/src/wp-includes/category-template.php +++ b/src/wp-includes/category-template.php @@ -43,6 +43,8 @@ function get_category_link( $category ) { * @param bool $nicename Optional. Whether to use nice name for display. Default false. * @param array $deprecated Not used. * @return string|WP_Error A list of category parents on success, WP_Error on failure. + * + * @phpstan-param array{} $deprecated */ function get_category_parents( $category_id, $link = false, $separator = '/', $nicename = false, $deprecated = array() ) { diff --git a/src/wp-includes/category.php b/src/wp-includes/category.php index e6085418e255d..1e8d9a79ff780 100644 --- a/src/wp-includes/category.php +++ b/src/wp-includes/category.php @@ -291,6 +291,10 @@ function cat_is_ancestor_of( $cat1, $cat2 ) { * @param object|array $category Category data. * @param string $context Optional. Default 'display'. * @return object|array Same type as $category with sanitized data for safe use. + * + * @phpstan-template T of array|object + * @phpstan-param T $category + * @phpstan-return T */ function sanitize_category( $category, $context = 'display' ) { return sanitize_term( $category, 'category', $context ); diff --git a/src/wp-includes/class-wp-ajax-response.php b/src/wp-includes/class-wp-ajax-response.php index ab747618e0fbf..b9946343ac79f 100644 --- a/src/wp-includes/class-wp-ajax-response.php +++ b/src/wp-includes/class-wp-ajax-response.php @@ -63,6 +63,8 @@ public function __construct( $args = '' ) { * element as CDATA. Default empty array. * } * @return string XML response. + * + * @phpstan-return non-falsy-string */ public function add( $args = '' ) { $defaults = array( diff --git a/src/wp-includes/class-wp-block-list.php b/src/wp-includes/class-wp-block-list.php index b56b3bd69dc3c..fb21ef75a5536 100644 --- a/src/wp-includes/class-wp-block-list.php +++ b/src/wp-includes/class-wp-block-list.php @@ -10,6 +10,8 @@ * Class representing a list of block instances. * * @since 5.5.0 + * + * @phpstan-implements ArrayAccess */ #[AllowDynamicProperties] class WP_Block_List implements Iterator, ArrayAccess, Countable { @@ -69,6 +71,8 @@ public function __construct( $blocks, $available_context = array(), $registry = * * @param int $offset Offset of block to check for. * @return bool Whether block exists. + * + * @phpstan-param int $offset */ #[ReturnTypeWillChange] public function offsetExists( $offset ) { @@ -84,6 +88,9 @@ public function offsetExists( $offset ) { * * @param int $offset Offset of block value to retrieve. * @return WP_Block|null Block value if exists, or null. + * + * @phpstan-param int $offset + * @phpstan-return WP_Block|null */ #[ReturnTypeWillChange] public function offsetGet( $offset ) { @@ -107,6 +114,9 @@ public function offsetGet( $offset ) { * * @param int $offset Offset of block value to set. * @param array|WP_Block $value Block value. + * + * @phpstan-param int|null $offset + * @phpstan-return void */ #[ReturnTypeWillChange] public function offsetSet( $offset, $value ) { @@ -125,6 +135,9 @@ public function offsetSet( $offset, $value ) { * @link https://www.php.net/manual/en/arrayaccess.offsetunset.php * * @param int $offset Offset of block value to unset. + * + * @phpstan-param int $offset + * @phpstan-return void */ #[ReturnTypeWillChange] public function offsetUnset( $offset ) { diff --git a/src/wp-includes/class-wp-block-supports.php b/src/wp-includes/class-wp-block-supports.php index cf2d84f3b6756..41cbe2b81c41a 100644 --- a/src/wp-includes/class-wp-block-supports.php +++ b/src/wp-includes/class-wp-block-supports.php @@ -197,6 +197,9 @@ private function register_attributes() { * * @param string[] $extra_attributes Optional. Array of extra attributes to render on the block wrapper. * @return string String of HTML attributes. + * + * @phpstan-param array $extra_attributes + * @phpstan-return ($extra_attributes is empty ? string : non-falsy-string) */ function get_block_wrapper_attributes( $extra_attributes = array() ) { $new_attributes = WP_Block_Supports::get_instance()->apply_block_supports(); diff --git a/src/wp-includes/class-wp-dependencies.php b/src/wp-includes/class-wp-dependencies.php index 80559201dda03..894e2bfbd32a6 100644 --- a/src/wp-includes/class-wp-dependencies.php +++ b/src/wp-includes/class-wp-dependencies.php @@ -74,6 +74,8 @@ class WP_Dependencies { * @since 2.8.0 * * @var (int|false)[] + * + * @phpstan-var array */ public $groups = array(); @@ -539,6 +541,8 @@ public function set_group( $handle, $recursion, $group ) { * * @param string[] $load Array of script or style handles to load. * @return string Etag header. + * + * @phpstan-return non-falsy-string */ public function get_etag( $load ) { /* diff --git a/src/wp-includes/class-wp-http.php b/src/wp-includes/class-wp-http.php index 13b82d95bfbd2..20d61ebf98cfb 100644 --- a/src/wp-includes/class-wp-http.php +++ b/src/wp-includes/class-wp-http.php @@ -633,6 +633,15 @@ private function _dispatch_request( $url, $args ) { * @param string|array $args Optional. Override the defaults. * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. * A WP_Error instance upon error. See WP_Http::response() for details. + * + * @phpstan-return array{ + * headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, + * body: string, + * response: array{code: int, message: string}, + * cookies: array, + * filename: string|null, + * http_response: WP_HTTP_Requests_Response, + * }|WP_Error */ public function post( $url, $args = array() ) { $defaults = array( 'method' => 'POST' ); @@ -651,6 +660,15 @@ public function post( $url, $args = array() ) { * @param string|array $args Optional. Override the defaults. * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. * A WP_Error instance upon error. See WP_Http::response() for details. + * + * @phpstan-return array{ + * headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, + * body: string, + * response: array{code: int, message: string}, + * cookies: array, + * filename: string|null, + * http_response: WP_HTTP_Requests_Response, + * }|WP_Error */ public function get( $url, $args = array() ) { $defaults = array( 'method' => 'GET' ); @@ -669,6 +687,15 @@ public function get( $url, $args = array() ) { * @param string|array $args Optional. Override the defaults. * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. * A WP_Error instance upon error. See WP_Http::response() for details. + * + * @phpstan-return array{ + * headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, + * body: string, + * response: array{code: int, message: string}, + * cookies: array, + * filename: string|null, + * http_response: WP_HTTP_Requests_Response, + * }|WP_Error */ public function head( $url, $args = array() ) { $defaults = array( 'method' => 'HEAD' ); diff --git a/src/wp-includes/class-wp-locale.php b/src/wp-includes/class-wp-locale.php index e18c0c4f1d897..37a2abf5cec53 100644 --- a/src/wp-includes/class-wp-locale.php +++ b/src/wp-includes/class-wp-locale.php @@ -119,6 +119,8 @@ class WP_Locale { * * @since 6.2.0 * @var string + * + * @phpstan-var 'characters_excluding_spaces'|'characters_including_spaces'|'words' */ public $word_count_type; @@ -442,6 +444,8 @@ public function get_list_item_separator() { * * @return string Localized word count type. Possible values are `characters_excluding_spaces`, * `characters_including_spaces`, or `words`. Defaults to `words`. + * + * @phpstan-return 'characters_excluding_spaces'|'characters_including_spaces'|'words' */ public function get_word_count_type() { diff --git a/src/wp-includes/class-wp-object-cache.php b/src/wp-includes/class-wp-object-cache.php index cda63e66d49ef..d79246ad2e3b0 100644 --- a/src/wp-includes/class-wp-object-cache.php +++ b/src/wp-includes/class-wp-object-cache.php @@ -420,6 +420,8 @@ public function get_multiple( $keys, $group = 'default', $force = false ) { * @param string $group Optional. Where the cache contents are grouped. Default 'default'. * @param bool $deprecated Optional. Unused. Default false. * @return bool True on success, false if the contents were not deleted. + * + * @phpstan-param false $deprecated */ public function delete( $key, $group = 'default', $deprecated = false ) { if ( ! $this->is_valid_key( $key ) ) { diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php index 513f0f702c61f..0fc2276bbc3de 100644 --- a/src/wp-includes/class-wp-query.php +++ b/src/wp-includes/class-wp-query.php @@ -14,6 +14,10 @@ * * @since 1.5.0 * @since 4.5.0 Removed the `$comments_popup` property. + * + * @phpstan-property-read bool $query_vars_changed + * @phpstan-property-read bool|string $query_vars_hash + * @phpstan-method void init_query_flags() */ #[AllowDynamicProperties] class WP_Query { diff --git a/src/wp-includes/class-wp-theme-json-resolver.php b/src/wp-includes/class-wp-theme-json-resolver.php index dc236f87907bb..05eedbcd40397 100644 --- a/src/wp-includes/class-wp-theme-json-resolver.php +++ b/src/wp-includes/class-wp-theme-json-resolver.php @@ -240,6 +240,8 @@ protected static function has_same_registered_blocks( $origin ) { * @type bool $with_supports Whether to include theme supports in the data. Default true. * } * @return WP_Theme_JSON Entity that holds theme data. + * + * @phpstan-param array{} $deprecated */ public static function get_theme_data( $deprecated = array(), $options = array() ) { if ( ! empty( $deprecated ) ) { diff --git a/src/wp-includes/class-wp-theme.php b/src/wp-includes/class-wp-theme.php index 87fcd7eec72b4..3b70c8bb81dd0 100644 --- a/src/wp-includes/class-wp-theme.php +++ b/src/wp-includes/class-wp-theme.php @@ -7,6 +7,20 @@ * @since 3.4.0 * * @phpstan-type Theme_Key 'Name'|'Version'|'Status'|'Title'|'Author'|'Author Name'|'Author URI'|'Description'|'Template'|'Stylesheet'|'Template Files'|'Stylesheet Files'|'Template Dir'|'Stylesheet Dir'|'Screenshot'|'Tags'|'Theme Root'|'Theme Root URI'|'Parent Theme' + * @phpstan-property-read string $name + * @phpstan-property-read string $title + * @phpstan-property-read string $version + * @phpstan-property-read string $parent_theme + * @phpstan-property-read string $template_dir + * @phpstan-property-read string $stylesheet_dir + * @phpstan-property-read string $template + * @phpstan-property-read string $stylesheet + * @phpstan-property-read string $screenshot + * @phpstan-property-read string $description + * @phpstan-property-read string $author + * @phpstan-property-read list $tags + * @phpstan-property-read string $theme_root + * @phpstan-property-read string $theme_root_uri */ #[AllowDynamicProperties] final class WP_Theme implements ArrayAccess { diff --git a/src/wp-includes/class-wp-widget-factory.php b/src/wp-includes/class-wp-widget-factory.php index 1f6ed3a58919e..24d3e05de0550 100644 --- a/src/wp-includes/class-wp-widget-factory.php +++ b/src/wp-includes/class-wp-widget-factory.php @@ -35,6 +35,7 @@ class WP_Widget_Factory { * @since 2.8.0 * @var array * @phpstan-var array + * @phpstan-var array */ public $widgets = array(); @@ -69,11 +70,14 @@ public function WP_Widget_Factory() { * @since 7.1.1 The key for an instance is prefixed so that it is never cast to an integer. * * @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass. + * + * @phpstan-param class-string|WP_Widget $widget */ public function register( $widget ) { if ( $widget instanceof WP_Widget ) { $this->widgets[ self::INSTANCE_KEY_PREFIX . spl_object_id( $widget ) ] = $widget; } else { + // @phpstan-ignore arguments.count (Widget classes declare their own constructor, which takes no arguments.) $this->widgets[ $widget ] = new $widget(); } } @@ -87,6 +91,8 @@ public function register( $widget ) { * @since 7.1.1 The key for an instance is prefixed so that it is never cast to an integer. * * @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass. + * + * @phpstan-param class-string|WP_Widget $widget */ public function unregister( $widget ) { if ( $widget instanceof WP_Widget ) { diff --git a/src/wp-includes/class-wp-widget.php b/src/wp-includes/class-wp-widget.php index b131c50db3226..9ae4f908af073 100644 --- a/src/wp-includes/class-wp-widget.php +++ b/src/wp-includes/class-wp-widget.php @@ -16,6 +16,8 @@ * * @since 2.8.0 * @since 4.4.0 Moved to its own file from wp-includes/widgets.php + * + * @phpstan-template T of array = array */ #[AllowDynamicProperties] class WP_Widget { @@ -109,6 +111,23 @@ class WP_Widget { * @param array $args Display arguments including 'before_title', 'after_title', * 'before_widget', and 'after_widget'. * @param array $instance The settings for the particular instance of the widget. + * + * @phpstan-param T $instance + * @phpstan-param array{ + * name: string, + * id: string, + * description: string, + * class: string, + * before_widget: string, + * after_widget: string, + * before_title: string, + * after_title: string, + * before_sidebar: string, + * after_sidebar: string, + * show_in_rest: boolean, + * widget_id: string, + * widget_name: string, + * } $args */ public function widget( $args, $instance ) { die( 'function WP_Widget::widget() must be overridden in a subclass.' ); @@ -127,6 +146,9 @@ public function widget( $args, $instance ) { * WP_Widget::form(). * @param array $old_instance Old settings for this instance. * @return array Settings to save or bool false to cancel saving. + * + * @phpstan-param T $new_instance + * @phpstan-param T $old_instance */ public function update( $new_instance, $old_instance ) { return $new_instance; @@ -140,6 +162,8 @@ public function update( $new_instance, $old_instance ) { * @param array $instance The settings for the particular instance of the widget. * @return string|void Default return is 'noform'. A subclass which echoes its own * form returns nothing. + * + * @phpstan-param T $instance */ public function form( $instance ) { echo '

' . __( 'There are no options for this widget.' ) . '

'; @@ -213,6 +237,8 @@ public function WP_Widget( $id_base, $name, $widget_options = array(), $control_ * * @param string $field_name Field name. * @return string Name attribute for `$field_name`. + * + * @phpstan-return non-falsy-string */ public function get_field_name( $field_name ) { $pos = strpos( $field_name, '[' ); @@ -238,6 +264,8 @@ public function get_field_name( $field_name ) { * * @param string $field_name Field name. * @return string ID attribute for `$field_name`. + * + * @phpstan-return non-falsy-string */ public function get_field_id( $field_name ) { $field_name = str_replace( array( '[]', '[', ']' ), array( '', '-', '' ), $field_name ); @@ -357,6 +385,8 @@ public function is_preview() { * * @type int $number Number increment used for multiples of the same widget. * } + * + * @final */ public function display_callback( $args, $widget_args = 1 ) { if ( is_numeric( $widget_args ) ) { @@ -408,6 +438,9 @@ public function display_callback( $args, $widget_args = 1 ) { * @global array $wp_registered_widgets * * @param int $deprecated Not used. + * + * @phpstan-param 1 $deprecated + * @final */ public function update_callback( $deprecated = 1 ) { global $wp_registered_widgets; @@ -500,6 +533,8 @@ public function update_callback( $deprecated = 1 ) { * @type int $number Number increment used for multiples of the same widget. * } * @return string|null + * + * @final */ public function form_callback( $widget_args = 1 ) { if ( is_numeric( $widget_args ) ) { diff --git a/src/wp-includes/class-wpdb.php b/src/wp-includes/class-wpdb.php index 869111efd0797..4ce20eb61ee0a 100644 --- a/src/wp-includes/class-wpdb.php +++ b/src/wp-includes/class-wpdb.php @@ -1465,6 +1465,8 @@ private function _escape_identifier_value( $identifier ) { * @param mixed ...$args Further variables to substitute into the query's placeholders * if being called with individual arguments. * @return string|null Sanitized query string, if there is a query to prepare. + * + * @phpstan-param literal-string $query */ public function prepare( $query, ...$args ) { if ( is_null( $query ) ) { @@ -3098,6 +3100,8 @@ public function get_var( $query = null, $x = 0, $y = 0 ) { * ) * : null * ) + * + * @phpstan-param int<0, max> $y */ public function get_row( $query = null, $output = OBJECT, $y = 0 ) { $this->func_call = "\$db->get_row(\"$query\",$output,$y)"; diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php index f7068362174e2..cc2608d4220e1 100644 --- a/src/wp-includes/comment-template.php +++ b/src/wp-includes/comment-template.php @@ -893,6 +893,9 @@ function get_comments_link( $post = 0 ) { * * @param string $deprecated Not Used. * @param string $deprecated_2 Not Used. + * + * @phpstan-param '' $deprecated + * @phpstan-param '' $deprecated_2 */ function comments_link( $deprecated = '', $deprecated_2 = '' ) { if ( ! empty( $deprecated ) ) { @@ -1279,6 +1282,8 @@ function trackback_url( $deprecated_echo = true ) { * @since 0.71 * * @param int|string $deprecated Not used (Was $timezone = 0). + * + * @phpstan-param '' $deprecated */ function trackback_rdf( $deprecated = '' ) { if ( ! empty( $deprecated ) ) { diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 9ad18180b78e9..488239f69201d 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -1899,6 +1899,8 @@ function wp_unspam_comment( $comment_id ) { * * @param int|WP_Comment $comment_id Comment ID or WP_Comment object * @return string|false Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure. + * + * @phpstan-return 'approved'|'spam'|'trash'|'unapproved'|false */ function wp_get_comment_status( $comment_id ) { $comment = get_comment( $comment_id ); @@ -3204,6 +3206,8 @@ function wp_update_comment_count_now( $post_id ) { * @param string $url URL to ping. * @param string $deprecated Not Used. * @return string|false String containing URI on success, false on failure. + * + * @phpstan-param '' $deprecated */ function discover_pingback_server_uri( $url, $deprecated = '' ) { if ( ! empty( $deprecated ) ) { diff --git a/src/wp-includes/cron.php b/src/wp-includes/cron.php index 743b37b326b25..83b1a8fc87673 100644 --- a/src/wp-includes/cron.php +++ b/src/wp-includes/cron.php @@ -45,6 +45,7 @@ * @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false. * @return bool|WP_Error True if event successfully scheduled. False or WP_Error on failure. * + * @phpstan-param list $args * @phpstan-return ( $wp_error is false ? bool : true|WP_Error ) */ function wp_schedule_single_event( $timestamp, $hook, $args = array(), $wp_error = false ) { @@ -251,6 +252,7 @@ function wp_schedule_single_event( $timestamp, $hook, $args = array(), $wp_error * @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false. * @return bool|WP_Error True if event successfully scheduled. False or WP_Error on failure. * + * @phpstan-param list $args * @phpstan-return ( $wp_error is false ? bool : true|WP_Error ) */ function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array(), $wp_error = false ) { @@ -368,6 +370,7 @@ function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array(), $wp * @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false. * @return bool|WP_Error True if event successfully rescheduled. False or WP_Error on failure. * + * @phpstan-param list $args * @phpstan-return ( $wp_error is false ? bool : true|WP_Error ) */ function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array(), $wp_error = false ) { @@ -492,6 +495,7 @@ function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array(), $ * @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false. * @return bool|WP_Error True if event successfully unscheduled. False or WP_Error on failure. * + * @phpstan-param list $args * @phpstan-return ( $wp_error is false ? bool : true|WP_Error ) */ function wp_unschedule_event( $timestamp, $hook, $args = array(), $wp_error = false ) { @@ -581,6 +585,7 @@ function wp_unschedule_event( $timestamp, $hook, $args = array(), $wp_error = fa * events were registered with the hook and arguments combination), false or WP_Error * if unscheduling one or more events fail. * + * @phpstan-param list $args * @phpstan-return ( int|( $wp_error is false ? false : WP_Error ) ) */ function wp_clear_scheduled_hook( $hook, $args = array(), $wp_error = false ) { @@ -786,6 +791,8 @@ function wp_unschedule_hook( $hook, $wp_error = false ) { * @type array $args Array containing each separate argument to pass to the hook's callback function. * @type int $interval Optional. The interval time in seconds for the schedule. Only present for recurring events. * } + * + * @phpstan-param list $args */ function wp_get_scheduled_event( $hook, $args = array(), $timestamp = null ) { /** @@ -867,6 +874,8 @@ function wp_get_scheduled_event( $hook, $args = array(), $timestamp = null ) { * event, so they must match those used when originally scheduling the event. If the * arguments do not match exactly, the event will not be found. Default empty array. * @return int|false The Unix timestamp (UTC) of the next time the event will occur. False if the event doesn't exist. + * + * @phpstan-param list $args */ function wp_next_scheduled( $hook, $args = array() ) { $next_event = wp_get_scheduled_event( $hook, $args ); @@ -1191,6 +1200,8 @@ function wp_get_schedules() { * @param array $args Optional. Arguments passed to the event's callback function. * Default empty array. * @return string|false Schedule name on success, false if no schedule. + * + * @phpstan-param list $args */ function wp_get_schedule( $hook, $args = array() ) { $schedule = false; diff --git a/src/wp-includes/deprecated.php b/src/wp-includes/deprecated.php index 76d3971085129..971a863134b9f 100644 --- a/src/wp-includes/deprecated.php +++ b/src/wp-includes/deprecated.php @@ -6524,6 +6524,7 @@ function wp_print_auto_sizes_contain_css_fix() { * @param string|array $gpc String or array of data to slash. * @return string|array Slashed `$gpc`. * + * @phpstan-pure * @phpstan-return ( $gpc is string ? string : array ) */ function addslashes_gpc( $gpc ) { diff --git a/src/wp-includes/feed.php b/src/wp-includes/feed.php index 7f9988b29f246..d4366556cf8a7 100644 --- a/src/wp-includes/feed.php +++ b/src/wp-includes/feed.php @@ -99,6 +99,8 @@ function get_default_feed() { * * @param string $deprecated Unused. * @return string The document title. + * + * @phpstan-param '–' $deprecated */ function get_wp_title_rss( $deprecated = '–' ) { if ( '–' !== $deprecated ) { @@ -125,6 +127,8 @@ function get_wp_title_rss( $deprecated = '–' ) { * @since 4.4.0 The optional `$sep` parameter was deprecated and renamed to `$deprecated`. * * @param string $deprecated Unused. + * + * @phpstan-param '–' $deprecated */ function wp_title_rss( $deprecated = '–' ) { if ( '–' !== $deprecated ) { @@ -595,6 +599,8 @@ function atom_enclosure() { * * @param string $data Input string. * @return array array(type, value) + * + * @phpstan-return array{'html'|'text'|'xhtml', string} */ function prep_atom_text_construct( $data ) { if ( ! str_contains( $data, '<' ) && ! str_contains( $data, '&' ) ) { diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index c39beaf7b1d68..bf7b696928f2d 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -611,6 +611,8 @@ function wpautop( $text, $br = true ) { * * @param string $input The text which has to be formatted. * @return string[] Array of the formatted text. + * + * @phpstan-return non-empty-list */ function wp_html_split( $input ) { return preg_split( get_html_split_regex(), $input, -1, PREG_SPLIT_DELIM_CAPTURE ); @@ -622,6 +624,8 @@ function wp_html_split( $input ) { * @since 4.4.0 * * @return string The regular expression. + * + * @phpstan-return non-falsy-string */ function get_html_split_regex() { static $regex; @@ -2278,6 +2282,9 @@ function sanitize_title_for_query( $title ) { * When set to 'save', additional entities are converted to hyphens * or stripped entirely. Default 'display'. * @return string The sanitized title. + * + * @phpstan-param 'display'|'save' $context + * @phpstan-return lowercase-string */ function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'display' ) { $title = strip_tags( $title ); @@ -2520,6 +2527,8 @@ function sanitize_locale_name( $locale_name ) { * @param string $content String of characters to be converted. * @param string $deprecated Not used. * @return string Converted string. + * + * @phpstan-param '' $deprecated */ function convert_chars( $content, $deprecated = '' ) { if ( ! empty( $deprecated ) ) { @@ -2821,6 +2830,7 @@ function format_to_edit( $content, $rich_text = false ) { * @param int $threshold Digit places number needs to be to not have zeros added. * @return string Adds leading zeros to number if needed. * + * @phpstan-param int<0, max> $threshold * @phpstan-return ( * $threshold is 0 * ? lowercase-string&non-empty-string&numeric-string @@ -2842,6 +2852,8 @@ function zeroise( $number, $threshold ) { * * @param string $value Value to which backslashes will be added. * @return string String with backslashes inserted. + * + * @phpstan-pure */ function backslashit( $value ) { if ( isset( $value[0] ) && $value[0] >= '0' && $value[0] <= '9' ) { @@ -2863,6 +2875,9 @@ function backslashit( $value ) { * * @param string $value Value to which trailing slash will be added. * @return string String with trailing slash added. + * + * @phpstan-pure + * @phpstan-return non-falsy-string */ function trailingslashit( $value ) { return untrailingslashit( $value ) . '/'; @@ -2878,6 +2893,8 @@ function trailingslashit( $value ) { * * @param string $value Value from which trailing slashes will be removed. * @return string String without the trailing slashes. + * + * @phpstan-pure */ function untrailingslashit( $value ) { return rtrim( $value, '/\\' ); @@ -2926,6 +2943,10 @@ function stripslashes_from_strings_only( $value ) { * * @param mixed $value The array or string to be encoded. * @return mixed The encoded value. + * + * @phpstan-template T + * @phpstan-param T $value + * @phpstan-return T */ function urlencode_deep( $value ) { return map_deep( $value, 'urlencode' ); @@ -2938,6 +2959,10 @@ function urlencode_deep( $value ) { * * @param mixed $value The array or string to be encoded. * @return mixed The encoded value. + * + * @phpstan-template T + * @phpstan-param T $value + * @phpstan-return T */ function rawurlencode_deep( $value ) { return map_deep( $value, 'rawurlencode' ); @@ -2950,6 +2975,10 @@ function rawurlencode_deep( $value ) { * * @param mixed $value The array or string to be decoded. * @return mixed The decoded value. + * + * @phpstan-template T + * @phpstan-param T $value + * @phpstan-return T */ function urldecode_deep( $value ) { return map_deep( $value, 'urldecode' ); @@ -2990,6 +3019,8 @@ function urldecode_deep( $value ) { * @param string $email_address Email address. * @param int $hex_encoding Optional. Set to 1 to enable hex encoding. * @return string Converted email address. + * + * @phpstan-param 0|1 $hex_encoding */ function antispambot( $email_address, $hex_encoding = 0 ) { $obfuscated = ''; @@ -3651,6 +3682,8 @@ function convert_smilies( $text ) { * @param string $email Email address to verify. * @param bool $deprecated Deprecated. * @return string|false Valid email address on success, false on failure. + * + * @phpstan-param false $deprecated */ function is_email( $email, $deprecated = false ) { if ( ! empty( $deprecated ) ) { @@ -5912,6 +5945,8 @@ function sanitize_trackback_urls( $to_ping ) { * T is array ? array, ( value-of is string ? string : value-of )> : T * ) * ) + * + * @phpstan-pure */ function wp_slash( $value ) { if ( is_array( $value ) ) { diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 393f50a3aad58..94560a20040b1 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -1005,6 +1005,8 @@ function do_enclose( $content, $post ) { * @param string $url URL to retrieve HTTP headers from. * @param bool $deprecated Not Used. * @return \WpOrg\Requests\Utility\CaseInsensitiveDictionary|false Headers on success, false on failure. + * + * @phpstan-param false $deprecated */ function wp_get_http_headers( $url, $deprecated = false ) { if ( ! empty( $deprecated ) ) { @@ -1034,6 +1036,8 @@ function wp_get_http_headers( $url, $deprecated = false ) { * @global string $previousday The day of the previous post in the loop. * * @return int 1 when new day, 0 if not a new day. + * + * @phpstan-return 0|1 */ function is_new_day() { global $currentday, $previousday; @@ -1613,6 +1617,7 @@ function get_num_queries() { * @param string $yn Character string containing either 'y' (yes) or 'n' (no). * @return bool True if 'y', false on anything else. * + * @phpstan-pure * @phpstan-return ( $yn is 'y'|'Y' ? true : false ) */ function bool_from_yn( $yn ) { @@ -1893,6 +1898,8 @@ function is_blog_installed() { * @param int|string $action Optional. Nonce action name. Default -1. * @param string $name Optional. Nonce name. Default '_wpnonce'. * @return string Escaped URL with nonce action added. + * + * @phpstan-param -1|string $action */ function wp_nonce_url( $actionurl, $action = -1, $name = '_wpnonce' ) { $actionurl = str_replace( '&', '&', $actionurl ); @@ -1924,6 +1931,8 @@ function wp_nonce_url( $actionurl, $action = -1, $name = '_wpnonce' ) { * @param bool $referer Optional. Whether to set the referer field for validation. Default true. * @param bool $display Optional. Whether to display or return hidden form field. Default true. * @return string Nonce field HTML markup. + * + * @phpstan-param -1|string $action */ function wp_nonce_field( $action = -1, $name = '_wpnonce', $referer = true, $display = true ) { $name = esc_attr( $name ); @@ -2146,6 +2155,7 @@ function wp_mkdir_p( $target ) { * @param string $path File path. * @return bool True if path is absolute, false is not absolute. * + * @phpstan-assert-if-true =non-falsy-string $path * @phpstan-return ( $path is non-falsy-string ? bool : false ) */ function path_is_absolute( $path ) { @@ -2189,6 +2199,8 @@ function path_is_absolute( $path ) { * @param string $base Base path. * @param string $path Path relative to $base. * @return string The path with the base or absolute path. + * + * @phpstan-return non-falsy-string */ function path_join( $base, $path ) { if ( path_is_absolute( $path ) ) { @@ -2955,6 +2967,9 @@ function _wp_check_existing_file_names( $filename, $files ) { * } * @phpstan-return array{ file: non-empty-string, url: non-empty-string, type: string|false, error: false } * |array{ error: string, ... } + * + * @phpstan-param non-empty-string $name + * @phpstan-param null $deprecated */ function wp_upload_bits( $name, $deprecated, $bits, $time = null ) { if ( ! empty( $deprecated ) ) { @@ -4475,6 +4490,9 @@ function _wp_die_process_input( $message, $title = '', $args = array() ) { * @param int $depth Optional. Maximum depth to walk through $value. Must be * greater than 0. Default 512. * @return string|false The JSON encoded string, or false if it cannot be encoded. + * + * @phpstan-param int<1, max> $depth + * @phpstan-return non-empty-string|false */ function wp_json_encode( $value, $flags = 0, $depth = 512 ) { $json = json_encode( $value, $flags, $depth ); @@ -5433,6 +5451,7 @@ function _wp_to_kebab_case( $input_string ) { * * @phpstan-assert-if-true array $data * + * @phpstan-pure * @phpstan-return ( $data is array ? true : false ) */ function wp_is_numeric_array( $data ): bool { @@ -6245,6 +6264,8 @@ function _doing_it_wrong( $function_name, $message, $version ) { * before passing to this function to avoid being stripped {@see wp_kses()}. * @param int $error_level Optional. The designated error type for this error. * Only works with E_USER family of constants. Default E_USER_NOTICE. + * + * @phpstan-param \E_USER_ERROR|\E_USER_WARNING|\E_USER_NOTICE|\E_USER_DEPRECATED $error_level */ function wp_trigger_error( $function_name, $message, $error_level = E_USER_NOTICE ) { /** @@ -7192,6 +7213,8 @@ function __return_false() { // phpcs:ignore WordPress.NamingConventions.ValidFun * @since 3.0.0 * * @return int 0. + * + * @phpstan-return 0 */ function __return_zero() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore return 0; @@ -7205,6 +7228,8 @@ function __return_zero() { // phpcs:ignore WordPress.NamingConventions.ValidFunc * @since 3.0.0 * * @return array Empty array. + * + * @phpstan-return array{} */ function __return_empty_array() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore return array(); @@ -7233,6 +7258,8 @@ function __return_null() { // phpcs:ignore WordPress.NamingConventions.ValidFunc * @see __return_null() * * @return string Empty string. + * + * @phpstan-return '' */ function __return_empty_string() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore return ''; @@ -7584,6 +7611,8 @@ function _device_can_upload() { * * @param string $path The resource path or URL. * @return bool True if the path is a stream URL. + * + * @phpstan-assert-if-true =non-falsy-string $path */ function wp_is_stream( $path ) { $scheme_separator = strpos( $path, '://' ); @@ -8172,6 +8201,9 @@ function wp_raise_memory_limit( $context = 'admin' ) { * @since 7.0.0 Uses wp_rand if available. * * @return string UUID. + * + * @phpstan-impure + * @phpstan-return lowercase-string&non-falsy-string */ function wp_generate_uuid4() { static $backup_randomizer = false; @@ -8210,6 +8242,9 @@ function wp_generate_uuid4() { * to accept any UUID version. Otherwise, only version allowed is `4`. * @return bool The string is a valid UUID or false on failure. * + * @phpstan-template TUuid of string + * @phpstan-param TUuid $uuid + * @phpstan-assert-if-true =TUuid&lowercase-string&non-falsy-string $uuid * @phpstan-return ( $version is 4|null ? bool : false ) */ function wp_is_uuid( $uuid, $version = null ) { @@ -8244,6 +8279,7 @@ function wp_is_uuid( $uuid, $version = null ) { * @param string $prefix Prefix for the returned ID. * @return string Unique ID. * + * @phpstan-impure * @phpstan-return ( * ( $prefix is ''|numeric-string ? numeric-string : string ) * & non-falsy-string @@ -8269,6 +8305,7 @@ function wp_unique_id( $prefix = '' ) { * @param string $prefix Optional. Prefix for the returned ID. Default empty string. * @return string Incremental ID per prefix. * + * @phpstan-impure * @phpstan-return ( * ( $prefix is ''|numeric-string ? numeric-string : string ) * & non-falsy-string @@ -8308,6 +8345,7 @@ function wp_unique_prefixed_id( $prefix = '' ) { * @param string $prefix Optional. A prefix to prepend to the generated ID. Default empty string. * @return string The generated unique ID for the array. * + * @phpstan-param non-empty-array $data * @phpstan-return ( $prefix is lowercase-string ? lowercase-string&non-falsy-string : non-falsy-string ) */ function wp_unique_id_from_values( array $data, string $prefix = '' ): string { @@ -9206,6 +9244,8 @@ function clean_dirsize_cache( $path ) { * @since 6.7.0 * * @return string The current WordPress version. + * + * @phpstan-return non-falsy-string */ function wp_get_wp_version() { static $wp_version; @@ -9473,6 +9513,8 @@ function wp_is_heic_image_mime_type( $mime_type ) { * * @param string $message The message to hash. * @return string The hash of the message. + * + * @phpstan-return non-falsy-string */ function wp_fast_hash( #[\SensitiveParameter] diff --git a/src/wp-includes/http.php b/src/wp-includes/http.php index 1a189a261306b..a049162dd846d 100644 --- a/src/wp-includes/http.php +++ b/src/wp-includes/http.php @@ -48,6 +48,15 @@ function _wp_http_get_object() { * See WP_Http::request() for information on accepted arguments. * @return array|WP_Error The response or WP_Error on failure. * See WP_Http::request() for information on return value. + * + * @phpstan-return array{ + * headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, + * body: string, + * response: array{code: int, message: string}, + * cookies: array, + * filename: string|null, + * http_response: WP_HTTP_Requests_Response, + * }|WP_Error */ function wp_safe_remote_request( $url, $args = array() ) { $args['reject_unsafe_urls'] = true; @@ -77,6 +86,15 @@ function wp_safe_remote_request( $url, $args = array() ) { * See WP_Http::request() for information on accepted arguments. * @return array|WP_Error The response or WP_Error on failure. * See WP_Http::request() for information on return value. + * + * @phpstan-return array{ + * headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, + * body: string, + * response: array{code: int, message: string}, + * cookies: array, + * filename: string|null, + * http_response: WP_HTTP_Requests_Response, + * }|WP_Error */ function wp_safe_remote_get( $url, $args = array() ) { $args['reject_unsafe_urls'] = true; @@ -106,6 +124,15 @@ function wp_safe_remote_get( $url, $args = array() ) { * See WP_Http::request() for information on accepted arguments. * @return array|WP_Error The response or WP_Error on failure. * See WP_Http::request() for information on return value. + * + * @phpstan-return array{ + * headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, + * body: string, + * response: array{code: int, message: string}, + * cookies: array, + * filename: string|null, + * http_response: WP_HTTP_Requests_Response, + * }|WP_Error */ function wp_safe_remote_post( $url, $args = array() ) { $args['reject_unsafe_urls'] = true; @@ -135,6 +162,15 @@ function wp_safe_remote_post( $url, $args = array() ) { * See WP_Http::request() for information on accepted arguments. * @return array|WP_Error The response or WP_Error on failure. * See WP_Http::request() for information on return value. + * + * @phpstan-return array{ + * headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, + * body: string, + * response: array{code: int, message: string}, + * cookies: array, + * filename: string|null, + * http_response: WP_HTTP_Requests_Response, + * }|WP_Error */ function wp_safe_remote_head( $url, $args = array() ) { $args['reject_unsafe_urls'] = true; @@ -162,6 +198,15 @@ function wp_safe_remote_head( $url, $args = array() ) { * See WP_Http::request() for information on accepted arguments. * @return array|WP_Error The response array or a WP_Error on failure. * See WP_Http::request() for information on return value. + * + * @phpstan-return array{ + * headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, + * body: string, + * response: array{code: int, message: string}, + * cookies: array, + * filename: string|null, + * http_response: WP_HTTP_Requests_Response, + * }|WP_Error */ function wp_remote_request( $url, $args = array() ) { $http = _wp_http_get_object(); @@ -183,6 +228,15 @@ function wp_remote_request( $url, $args = array() ) { * See WP_Http::request() for information on accepted arguments. * @return array|WP_Error The response or WP_Error on failure. * See WP_Http::request() for information on return value. + * + * @phpstan-return array{ + * headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, + * body: string, + * response: array{code: int, message: string}, + * cookies: array, + * filename: string|null, + * http_response: WP_HTTP_Requests_Response, + * }|WP_Error */ function wp_remote_get( $url, $args = array() ) { $http = _wp_http_get_object(); @@ -204,6 +258,15 @@ function wp_remote_get( $url, $args = array() ) { * See WP_Http::request() for information on accepted arguments. * @return array|WP_Error The response or WP_Error on failure. * See WP_Http::request() for information on return value. + * + * @phpstan-return array{ + * headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, + * body: string, + * response: array{code: int, message: string}, + * cookies: array, + * filename: string|null, + * http_response: WP_HTTP_Requests_Response, + * }|WP_Error */ function wp_remote_post( $url, $args = array() ) { $http = _wp_http_get_object(); @@ -225,6 +288,15 @@ function wp_remote_post( $url, $args = array() ) { * See WP_Http::request() for information on accepted arguments. * @return array|WP_Error The response or WP_Error on failure. * See WP_Http::request() for information on return value. + * + * @phpstan-return array{ + * headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, + * body: string, + * response: array{code: int, message: string}, + * cookies: array, + * filename: string|null, + * http_response: WP_HTTP_Requests_Response, + * }|WP_Error */ function wp_remote_head( $url, $args = array() ) { $http = _wp_http_get_object(); @@ -556,6 +628,8 @@ function send_origin_headers() { * @param string $url Request URL. * @return string|false Returns false if the URL is not safe, or the original URL if it is safe. * + * @phpstan-template TUrl of string + * @phpstan-param TUrl $url * @phpstan-return ( $url is numeric|'' ? false : string|false ) */ function wp_http_validate_url( $url ) { diff --git a/src/wp-includes/kses.php b/src/wp-includes/kses.php index f6ef8a1ed194f..b273b4b1629ac 100644 --- a/src/wp-includes/kses.php +++ b/src/wp-includes/kses.php @@ -2644,6 +2644,8 @@ function kses_init() { * @param string $css A string of CSS rules, decoded from an HTML `style` attribute. * @param string $deprecated Not used. * @return string Filtered string of CSS rules, needing HTML escaping before sending back to a `style` attribute. + * + * @phpstan-param '' $deprecated */ function safecss_filter_attr( $css, $deprecated = '' ) { if ( ! empty( $deprecated ) ) { diff --git a/src/wp-includes/l10n.php b/src/wp-includes/l10n.php index 7b9d2652d41dd..95c41fb3f6bdc 100644 --- a/src/wp-includes/l10n.php +++ b/src/wp-includes/l10n.php @@ -995,6 +995,8 @@ function load_default_textdomain( $locale = null ) { * @param string|false $plugin_rel_path Optional. Relative path to WP_PLUGIN_DIR where the .mo file resides. * Default false. * @return bool True when textdomain is successfully loaded, false otherwise. + * + * @phpstan-param false $deprecated */ function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path = false ) { /** @var WP_Textdomain_Registry $wp_textdomain_registry */ @@ -2066,6 +2068,8 @@ function wp_get_list_item_separator() { * * @return string Locale-specific word count type. Possible values are `characters_excluding_spaces`, * `characters_including_spaces`, or `words`. Defaults to `words`. + * + * @phpstan-return 'characters_excluding_spaces'|'characters_including_spaces'|'words' */ function wp_get_word_count_type() { global $wp_locale; diff --git a/src/wp-includes/l10n/class-wp-translations.php b/src/wp-includes/l10n/class-wp-translations.php index 2cccf542d8b3b..9baacd94b6d7a 100644 --- a/src/wp-includes/l10n/class-wp-translations.php +++ b/src/wp-includes/l10n/class-wp-translations.php @@ -115,6 +115,7 @@ private function make_entry( $original, $translations ): Translation_Entry { * * @phpstan-template T of string|null * @phpstan-param T $singular + * @phpstan-param int $count * @phpstan-return ( $singular is null ? null : ( $plural is null ? T : string ) ) */ public function translate_plural( $singular, $plural, $count = 1, $context = '' ) { diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index 3d4ffc23b8f62..976c024b94d7d 100644 --- a/src/wp-includes/link-template.php +++ b/src/wp-includes/link-template.php @@ -1560,6 +1560,8 @@ function edit_post_link( $text = null, $before = '', $after = '', $post = 0, $cs * @param string $deprecated Not used. * @param bool $force_delete Optional. Whether to bypass Trash and force deletion. Default false. * @return string|null The delete post link URL for the given post. + * + * @phpstan-param '' $deprecated */ function get_delete_post_link( $post = 0, $deprecated = '', $force_delete = false ) { if ( ! empty( $deprecated ) ) { @@ -4887,6 +4889,8 @@ function get_the_privacy_policy_link( $before = '', $after = '' ) { * @since 6.2.0 * * @return string[] An array of URL hosts. + * + * @phpstan-return array */ function wp_internal_hosts() { static $internal_hosts; diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php index 1558a44189226..6ac13f24b8268 100644 --- a/src/wp-includes/load.php +++ b/src/wp-includes/load.php @@ -11,6 +11,8 @@ * @since 4.4.0 * * @return string The HTTP protocol. Default: HTTP/1.0. + * + * @phpstan-return 'HTTP/1.0'|'HTTP/1.1'|'HTTP/2'|'HTTP/2.0'|'HTTP/3' */ function wp_get_server_protocol() { $protocol = $_SERVER['SERVER_PROTOCOL'] ?? ''; @@ -1509,6 +1511,8 @@ function absint( $maybeint ): int { * @global int $blog_id * * @return int Site ID. + * + * @phpstan-return int<0, max> */ function get_current_blog_id() { global $blog_id; diff --git a/src/wp-includes/meta.php b/src/wp-includes/meta.php index 6adcf389d5884..765ce96e58a9f 100644 --- a/src/wp-includes/meta.php +++ b/src/wp-includes/meta.php @@ -1490,6 +1490,8 @@ function sanitize_meta( $meta_key, $meta_value, $object_type, $object_subtype = * @return bool True if the meta key was successfully registered in the global array, false if not. * Registering a meta key with distinct sanitize and auth callbacks will fire those callbacks, * but will not add to the global registry. + * + * @phpstan-param null $deprecated */ function register_meta( $object_type, $meta_key, $args, $deprecated = null ) { global $wp_meta_keys; diff --git a/src/wp-includes/ms-blogs.php b/src/wp-includes/ms-blogs.php index c54563fbbd2b8..2ac766ffc37ad 100644 --- a/src/wp-includes/ms-blogs.php +++ b/src/wp-includes/ms-blogs.php @@ -456,6 +456,8 @@ function delete_blog_option( $id, $option ) { * @param mixed $value The option value. * @param mixed $deprecated Not used. * @return bool True if the value was updated, false otherwise. + * + * @phpstan-param null $deprecated */ function update_blog_option( $id, $option, $value, $deprecated = null ) { $id = (int) $id; @@ -496,6 +498,8 @@ function update_blog_option( $id, $option, $value, $deprecated = null ) { * @param int $new_blog_id The ID of the blog to switch to. Default: current blog. * @param bool $deprecated Not used. * @return true Always returns true. + * + * @phpstan-param null $deprecated */ function switch_to_blog( $new_blog_id, $deprecated = null ) { global $wpdb; @@ -819,6 +823,8 @@ function get_blog_status( $id, $pref ) { * Can be used for pagination. Default 0. * @param int $quantity Optional. The maximum number of blogs to retrieve. Default 40. * @return array The list of blogs. + * + * @phpstan-param '' $deprecated */ function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) { global $wpdb; diff --git a/src/wp-includes/ms-functions.php b/src/wp-includes/ms-functions.php index 81dda98f3e312..46fe2537d8521 100644 --- a/src/wp-includes/ms-functions.php +++ b/src/wp-includes/ms-functions.php @@ -1478,6 +1478,8 @@ function wpmu_create_blog( $domain, $path, $title, $user_id, $options = array(), * @param WP_Site|int $blog_id The new site's object or ID. * @param string $deprecated Not used. * @return bool + * + * @phpstan-param '' $deprecated */ function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) { if ( is_object( $blog_id ) ) { @@ -2088,6 +2090,8 @@ function check_upload_mimes( $mimes ) { * @global wpdb $wpdb WordPress database abstraction object. * * @param string $deprecated Not used. + * + * @phpstan-param '' $deprecated */ function update_posts_count( $deprecated = '' ) { global $wpdb; @@ -2142,6 +2146,8 @@ function wpmu_log_new_registrations( $blog_id, $user_id ) { * * @type string $0 The current site's domain. * } + * + * @phpstan-param '' $deprecated */ function redirect_this_site( $deprecated = '' ) { return array( get_network()->domain ); diff --git a/src/wp-includes/nav-menu.php b/src/wp-includes/nav-menu.php index ed49892ac0eb6..269a26b5c50d5 100644 --- a/src/wp-includes/nav-menu.php +++ b/src/wp-includes/nav-menu.php @@ -86,6 +86,8 @@ function is_nav_menu( $menu ) { * @global array $_wp_registered_nav_menus * * @param string[] $locations Associative array of menu location identifiers (like a slug) and descriptive text. + * + * @phpstan-param array $locations */ function register_nav_menus( $locations = array() ) { global $_wp_registered_nav_menus; diff --git a/src/wp-includes/option.php b/src/wp-includes/option.php index d5c179c645af3..f32f518d35580 100644 --- a/src/wp-includes/option.php +++ b/src/wp-includes/option.php @@ -1065,6 +1065,8 @@ function update_option( $option, $value, $autoload = null ) { * to not autoload them, by using false. * Default is null, which means WordPress will determine the autoload value. * @return bool True if the option was added, false otherwise. + * + * @phpstan-param '' $deprecated */ function add_option( $option, $value = '', $deprecated = '', $autoload = null ) { global $wpdb; @@ -1427,6 +1429,8 @@ function delete_transient( $transient ) { * * @param string $transient Transient name. Expected to not be SQL-escaped. * @return mixed Value of transient. + * + * @phpstan-impure */ function get_transient( $transient ) { @@ -1930,6 +1934,8 @@ function delete_all_user_settings() { * @param mixed $default_value Optional. Value to return if the option doesn't exist. Default false. * @param bool $deprecated Whether to use cache. Multisite only. Always set to true. * @return mixed Value set for the option. + * + * @phpstan-param true $deprecated */ function get_site_option( $option, $default_value = false, $deprecated = true ) { return get_network_option( null, $option, $default_value ); @@ -3119,6 +3125,8 @@ function register_setting( $option_group, $option_name, $args = array() ) { * @param string $option_group The settings group name used during registration. * @param string $option_name The name of the option to unregister. * @param callable $deprecated Optional. Deprecated. + * + * @phpstan-param '' $deprecated */ function unregister_setting( $option_group, $option_name, $deprecated = '' ) { global $new_allowed_options, $wp_registered_settings; diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index 4126f25d7c0fc..c86f36e2316c2 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -191,6 +191,8 @@ function cache_users( $user_ids ) { * @param string|string[] $attachments Optional. Paths to files to attach. * @param string|string[] $embeds Optional. Paths to files to embed. * @return bool Whether the email was sent successfully. + * + * @phpstan-impure */ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array(), $embeds = array() ) { // Compact the input, apply the filters, and extract them back out. @@ -2447,6 +2449,9 @@ function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' ) * * @param string|int $action Optional. The nonce action. Default -1. * @return float Float value rounded up to the next highest integer. + * + * @phpstan-param -1|string $action + * @phpstan-impure */ function wp_nonce_tick( $action = -1 ) { /** @@ -2477,6 +2482,9 @@ function wp_nonce_tick( $action = -1 ) { * @return int|false 1 if the nonce is valid and generated between 0-12 hours ago, * 2 if the nonce is valid and generated between 12-24 hours ago. * False if the nonce is invalid. + * + * @phpstan-param -1|string $action + * @phpstan-return 1|2|false */ function wp_verify_nonce( $nonce, $action = -1 ) { $nonce = (string) $nonce; @@ -2540,6 +2548,9 @@ function wp_verify_nonce( $nonce, $action = -1 ) { * * @param string|int $action Scalar value to add context to the nonce. * @return string The token. + * + * @phpstan-param -1|string $action + * @phpstan-return lowercase-string&non-falsy-string */ function wp_create_nonce( $action = -1 ) { $user = wp_get_current_user(); @@ -2722,6 +2733,9 @@ function wp_salt( $scheme = 'auth' ) { * @param string $scheme Authentication scheme (auth, secure_auth, logged_in, nonce). * @param string $algo Hashing algorithm to use. Default: 'md5'. * @return string Hash of $data. + * + * @phpstan-param 'auth'|'logged_in'|'nonce'|'secure_auth' $scheme + * @phpstan-return lowercase-string&non-falsy-string */ function wp_hash( $data, $scheme = 'auth', $algo = 'md5' ) { $salt = wp_salt( $scheme ); @@ -2967,6 +2981,8 @@ function wp_password_needs_rehash( $hash, $user_id = '' ) { * @param bool $extra_special_chars Optional. Whether to include other special characters. * Used when generating secret keys and salts. Default false. * @return string The random password. + * + * @phpstan-impure */ function wp_generate_password( $length = 12, $special_chars = true, $extra_special_chars = false ) { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; @@ -3012,6 +3028,8 @@ function wp_generate_password( $length = 12, $special_chars = true, $extra_speci * @param int $max Optional. Upper limit for the generated number. * Accepts positive integers. Defaults to 4294967295. * @return int A random non-negative number between min and max. + * + * @phpstan-impure */ function wp_rand( $min = null, $max = null ) { global $rnd_value; diff --git a/src/wp-includes/plugin.php b/src/wp-includes/plugin.php index a3e9afacdb8dc..bc46448454774 100644 --- a/src/wp-includes/plugin.php +++ b/src/wp-includes/plugin.php @@ -171,6 +171,8 @@ function add_filter( $hook_name, $callback, $priority = 10, $accepted_args = 1 ) * @param mixed ...$args Optional. Additional parameters to pass to the callback functions. * @no-named-arguments * @return mixed The filtered value after all hooked functions are applied to it. + * + * @phpstan-param non-empty-string $hook_name */ function apply_filters( $hook_name, $value, ...$args ) { global $wp_filter, $wp_filters, $wp_current_filter; @@ -226,6 +228,8 @@ function apply_filters( $hook_name, $value, ...$args ) { * @param string $hook_name The name of the filter hook. * @param non-empty-list $args The arguments supplied to the functions hooked to `$hook_name`. * @return mixed The filtered value after all hooked functions are applied to it. + * + * @phpstan-param non-empty-string $hook_name */ function apply_filters_ref_array( $hook_name, $args ) { global $wp_filter, $wp_filters, $wp_current_filter; @@ -376,6 +380,8 @@ function remove_all_filters( $hook_name, $priority = false ) { * @global string[] $wp_current_filter Stores the list of current filters with the current one last * * @return string|false Hook name of the current filter, false if no filter is running. + * + * @phpstan-return non-empty-string|false */ function current_filter() { global $wp_current_filter; @@ -423,6 +429,8 @@ function doing_filter( $hook_name = null ) { * * @param string $hook_name The name of the filter hook. * @return int The number of times the filter hook has been applied. + * + * @phpstan-return int<0, max> */ function did_filter( $hook_name ) { global $wp_filters; @@ -495,6 +503,8 @@ function add_action( $hook_name, $callback, $priority = 10, $accepted_args = 1 ) * @param mixed ...$arg Optional. Additional arguments which are passed on to the * functions hooked to the action. Default empty. * @no-named-arguments + * + * @phpstan-param non-empty-string $hook_name */ function do_action( $hook_name, ...$arg ) { global $wp_filter, $wp_actions, $wp_current_filter; @@ -550,6 +560,8 @@ function do_action( $hook_name, ...$arg ) { * * @param string $hook_name The name of the action to be executed. * @param list $args The arguments supplied to the functions hooked to `$hook_name`. + * + * @phpstan-param non-empty-string $hook_name */ function do_action_ref_array( $hook_name, $args ) { global $wp_filter, $wp_actions, $wp_current_filter; @@ -664,6 +676,8 @@ function remove_all_actions( $hook_name, $priority = false ) { * @since 3.9.0 * * @return string|false Hook name of the current action, false if no action is running. + * + * @phpstan-return non-empty-string|false */ function current_action() { return current_filter(); @@ -702,6 +716,8 @@ function doing_action( $hook_name = null ) { * * @param string $hook_name The name of the action hook. * @return int The number of times the action hook has been fired. + * + * @phpstan-return int<0, max> */ function did_action( $hook_name ) { global $wp_actions; @@ -739,6 +755,8 @@ function did_action( $hook_name ) { * @param string $replacement Optional. The hook that should have been used. Default empty. * @param string $message Optional. A message regarding the change. Default empty. * @return mixed The filtered value after all hooked functions are applied to it. + * + * @phpstan-param non-empty-string $hook_name */ function apply_filters_deprecated( $hook_name, $args, $version, $replacement = '', $message = '' ) { if ( ! has_filter( $hook_name ) ) { @@ -766,6 +784,8 @@ function apply_filters_deprecated( $hook_name, $args, $version, $replacement = ' * @param string $version The version of WordPress that deprecated the hook. * @param string $replacement Optional. The hook that should have been used. Default empty. * @param string $message Optional. A message regarding the change. Default empty. + * + * @phpstan-param non-empty-string $hook_name */ function do_action_deprecated( $hook_name, $args, $version, $replacement = '', $message = '' ) { if ( ! has_action( $hook_name ) ) { @@ -896,6 +916,9 @@ function plugin_dir_url( $file ) { * * @param string $file The filename of the plugin including the path. * @param callable $callback The function hooked to the 'activate_PLUGIN' action. + * + * @phpstan-param callable(bool): void $callback + * @phpstan-return void */ function register_activation_hook( $file, $callback ) { $file = plugin_basename( $file ); @@ -919,6 +942,9 @@ function register_activation_hook( $file, $callback ) { * * @param string $file The filename of the plugin including the path. * @param callable $callback The function hooked to the 'deactivate_PLUGIN' action. + * + * @phpstan-param callable(bool): void $callback + * @phpstan-return void */ function register_deactivation_hook( $file, $callback ) { $file = plugin_basename( $file ); @@ -950,6 +976,8 @@ function register_deactivation_hook( $file, $callback ) { * @param string $file Plugin file. * @param callable $callback The callback to run when the hook is called. Must be * a static method or function. + * + * @phpstan-param callable(): void $callback */ function register_uninstall_hook( $file, $callback ) { if ( is_array( $callback ) && is_object( $callback[0] ) ) { diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php index b817653aaf0ec..20a5424e362a1 100644 --- a/src/wp-includes/post-template.php +++ b/src/wp-includes/post-template.php @@ -1640,6 +1640,8 @@ function walk_page_dropdown_tree( ...$args ) { * @param bool $fullsize Optional. Whether to use full size. Default false. * @param bool $deprecated Deprecated. Not used. * @param bool $permalink Optional. Whether to include permalink. Default false. + * + * @phpstan-param false $deprecated */ function the_attachment_link( $post = 0, $fullsize = false, $deprecated = false, $permalink = false ) { if ( ! empty( $deprecated ) ) { @@ -2054,6 +2056,8 @@ function wp_post_revision_title_expanded( $revision, $link = true ) { * * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. * @param string $type 'all' (default), 'revision' or 'autosave' + * + * @phpstan-param 'all'|'revision'|'autosave' $type */ function wp_list_post_revisions( $post = 0, $type = 'all' ) { $post = get_post( $post ); diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 5edc8a50f0299..933c5f874c1bf 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -1828,6 +1828,8 @@ function get_post_types( $args = array(), $output = 'names', $operator = 'and' ) * } * @return WP_Post_Type|WP_Error The registered post type object on success, * WP_Error object on failure. + * + * @phpstan-param lowercase-string&non-empty-string $post_type */ function register_post_type( $post_type, $args = array() ) { global $wp_post_types; diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php index 36b5b23de9f00..86e308b29db8f 100644 --- a/src/wp-includes/rest-api.php +++ b/src/wp-includes/rest-api.php @@ -30,6 +30,9 @@ * @param bool $override Optional. If the route already exists, should we override it? True overrides, * false merges (with newer overriding if duplicate keys exist). Default false. * @return bool True on success, false on error. + * + * @phpstan-param non-falsy-string $route_namespace + * @phpstan-param non-falsy-string $route */ function register_rest_route( $route_namespace, $route, $args = array(), $override = false ) { if ( empty( $route_namespace ) ) { @@ -1436,6 +1439,8 @@ function rest_get_date_with_gmt( $date, $is_utc = false ) { * @since 4.7.0 * * @return int 401 if the user is not logged in, 403 if the user is logged in. + * + * @phpstan-return 401|403 */ function rest_authorization_required_code() { return is_user_logged_in() ? 403 : 401; @@ -1534,6 +1539,9 @@ function rest_is_ip_address( $ip ) { * @param bool|string|int $value The value being evaluated. * @return bool Returns the proper associated boolean value. * + * @phpstan-template T of bool|string|int + * @phpstan-param T $value + * @phpstan-pure * @phpstan-return ( * $value is false|''|'0'|0|'false'|'False'|'FALSE' * ? false diff --git a/src/wp-includes/revision.php b/src/wp-includes/revision.php index 31bbceeb4ec9c..179a32c2832c5 100644 --- a/src/wp-includes/revision.php +++ b/src/wp-includes/revision.php @@ -18,6 +18,8 @@ * for insertion as a post revision. Default empty array. * @param bool $deprecated Not used. * @return string[] Array of fields that can be versioned. + * + * @phpstan-param false $deprecated */ function _wp_post_revision_fields( $post = array(), $deprecated = false ) { static $fields = null; diff --git a/src/wp-includes/rewrite.php b/src/wp-includes/rewrite.php index 976d2a014b9db..0ac4b08f3ffc0 100644 --- a/src/wp-includes/rewrite.php +++ b/src/wp-includes/rewrite.php @@ -247,6 +247,9 @@ function remove_permastruct( $name ) { * @param string $feedname Feed name. Should not start with '_'. * @param callable $callback Callback to run on feed display. * @return string Feed action name. + * + * @phpstan-param callable(bool, string): void $callback + * @phpstan-return non-falsy-string */ function add_feed( $feedname, $callback ) { global $wp_rewrite; diff --git a/src/wp-includes/robots-template.php b/src/wp-includes/robots-template.php index e719e745d61e7..14657f74340b0 100644 --- a/src/wp-includes/robots-template.php +++ b/src/wp-includes/robots-template.php @@ -66,6 +66,9 @@ function wp_robots() { * * @param array $robots Associative array of robots directives. * @return array Filtered robots directives. + * + * @phpstan-param array $robots + * @phpstan-return array */ function wp_robots_noindex( array $robots ) { if ( ! get_option( 'blog_public' ) ) { @@ -88,6 +91,9 @@ function wp_robots_noindex( array $robots ) { * * @param array $robots Associative array of robots directives. * @return array Filtered robots directives. + * + * @phpstan-param array $robots + * @phpstan-return array */ function wp_robots_noindex_embeds( array $robots ) { if ( is_embed() ) { @@ -114,6 +120,9 @@ function wp_robots_noindex_embeds( array $robots ) { * * @param array $robots Associative array of robots directives. * @return array Filtered robots directives. + * + * @phpstan-param array $robots + * @phpstan-return array */ function wp_robots_noindex_search( array $robots ) { if ( is_search() ) { @@ -136,6 +145,9 @@ function wp_robots_noindex_search( array $robots ) { * * @param array $robots Associative array of robots directives. * @return array Filtered robots directives. + * + * @phpstan-param array $robots + * @phpstan-return array */ function wp_robots_no_robots( array $robots ) { $robots['noindex'] = true; @@ -163,6 +175,9 @@ function wp_robots_no_robots( array $robots ) { * * @param array $robots Associative array of robots directives. * @return array Filtered robots directives. + * + * @phpstan-param array $robots + * @phpstan-return array */ function wp_robots_sensitive_page( array $robots ) { $robots['noindex'] = true; @@ -184,6 +199,9 @@ function wp_robots_sensitive_page( array $robots ) { * * @param array $robots Associative array of robots directives. * @return array Filtered robots directives. + * + * @phpstan-param array $robots + * @phpstan-return array */ function wp_robots_max_image_preview_large( array $robots ) { if ( get_option( 'blog_public' ) ) { diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 6b01efa1718ce..5d6ed38f22203 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -685,6 +685,8 @@ function wp_default_packages( $scripts ) { * * @param string $type The type of suffix to retrieve. * @return string The script suffix. + * + * @phpstan-return ''|'.min' */ function wp_scripts_get_suffix( $type = '' ) { static $suffixes; @@ -2939,6 +2941,9 @@ function wp_enqueue_editor_format_library_assets() { * * @param array $attributes Key-value pairs representing `