Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7fa3597
Docs: Add refined string types to PHPStan return and parameter types.
swissspidy Oct 1, 2026
d83c939
Merge remote-tracking branch 'upstream/trunk' into fix/phpstan-strings
claude Oct 5, 2026
073ece9
Docs: Address review feedback on string types.
claude Oct 5, 2026
961506e
Merge remote-tracking branch 'upstream/trunk' into fix/phpstan-strings
claude Oct 7, 2026
8ccf26c
Merge branch 'trunk' into fix/phpstan-strings
westonruter Oct 7, 2026
31fa5b2
Assert the type of `$wp_version` in `wp_get_wp_version()`.
westonruter Oct 7, 2026
8290702
Type the static `$regex` in `get_html_split_regex()`.
westonruter Oct 7, 2026
5a8cf6b
Assert the lowercase return type of `sanitize_title_with_dashes()`.
westonruter Oct 7, 2026
4ccdf6a
Return a list of lowercase hosts from `wp_internal_hosts()`.
westonruter Oct 7, 2026
172abeb
Assert the lowercase return type of `wp_generate_uuid4()`.
westonruter Oct 7, 2026
b969408
Assert a non-falsy path when `path_is_absolute()` returns true.
westonruter Oct 7, 2026
c7ab136
Narrow the taxonomy key type for `register_taxonomy()`.
westonruter Oct 7, 2026
f4474a9
Narrow the post status name type for `register_post_status()`.
westonruter Oct 7, 2026
cba30d8
Narrow the ability and ability category name types.
westonruter Oct 7, 2026
c8cd212
Narrow the block bindings source name type.
westonruter Oct 7, 2026
a51d0e1
Narrow the icon and icon collection name types.
westonruter Oct 7, 2026
660115f
Narrow the connector ID type.
westonruter Oct 7, 2026
b36cc6e
Narrow the block type name type in the block type registry.
westonruter Oct 7, 2026
b21d89e
Narrow the block template name type.
westonruter Oct 7, 2026
4eb2a8d
Narrow the menu slug type for admin menu page functions.
westonruter Oct 7, 2026
1b05091
Use `@phpstan-var` for the icon manifest array shape.
westonruter Oct 7, 2026
a88ab20
Use `@var` again for the icon manifest array shape.
westonruter Oct 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/wp-admin/includes/class-wp-comments-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

@dmsnell dmsnell Oct 7, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like we have been adding a lot of aspirational, but wrong type annotations lately, and I’m really concerned about the choices we’re making in response to PHPStan warnings.

is it not obvious by inspection that this can return a false string? maybe I’m wrong, but it seems like get_comment() can return null and get_avatar() can return false, which leads to string(1) " " which itself is falsy.

if this is the case, these more-frequent invalid type annotations only hide type errors and make them harder to find, and they taint the type checking even further by asserting that the type is not what the code says, but that there is some reason to trust us rather than the code.

at least this won’t case crashes, being the docblock annotation, but it can still cause headaches when debugging why a false appears where the type system claims it cannot

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, " " is truthy: https://3v4l.org/Ft5fq#veol

Otherwise, if it had indeed been falsy, then an aspirational type would be wrong.

If there is any other example which is aspirational you see, I'm happy to revisit!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the choices we’re making in response to PHPStan warnings.

Also, most of these narrowed types here are not to address any warnings. They are intended to improve correctness so that callers and callees have as specific type information available.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for refuting me on that @westonruter

mostly it’s with these dependent-type annotations like non-empty-string or non-empty-array — these seem frail, and by aspirational I mean it’s what we expect, but not necessarily what can occur.

I tend to skip over these without too much thought, and maybe every time I see them I’m wrong, so I’ll try and pay more attention, though I definitely cannot keep up with the pace of PHPStan changes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmsnell The hope is that you won't have to think about these. We can offload the thinking to PHPStan. If the method here is ever modified to do something like this instead:

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 7294f89d1b..419427b6ce 100644
--- a/src/wp-admin/includes/class-wp-comments-list-table.php
+++ b/src/wp-admin/includes/class-wp-comments-list-table.php
@@ -68,7 +68,7 @@ class WP_Comments_List_Table extends WP_List_Table {
 	public function floated_admin_avatar( $name, $comment_id ) {
 		$comment = get_comment( $comment_id );
 		$avatar  = get_avatar( $comment, 32, 'mystery' );
-		return "$avatar $name";
+		return $avatar . $name;
 	}
 
 	/**

Then PHPStan would raise an error here:

  71     Method WP_Comments_List_Table::floated_admin_avatar() should return non-falsy-string but returns string.                                                  
         🪪  return.type                                                                                                                                           
         at src/wp-admin/includes/class-wp-comments-list-table.php:71    

In this way, I don't think they are frail. They are being checked for their truthfulness (and truthiness!)

The hope is that having these narrowed types will allow users of the method to avoid dead code. For example, if someone did this:

$avatar = $list_table->floated_admin_avatar( 'John Smith', 1 );
if ( $avatar ) {
	echo "<div>$avatar</div>";
} else {
	echo "<div>NO AVATAR!</div>"; // DEAD CODE!
}

Then PHPStan can flag the if() condition as an if.alwaysTrue error.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then PHPStan would raise an error here…don’t think they are frail

if we’re overly conservative that seems fine, but we are seeming to be overly-optimistic in these situations.

it seems that either way, in this case with the comment and avatar, things are not changed, but some strings are falsey, like "0". and I think the abs_int() example is illustrative.

PHP and WP code generally has done a poor job of indicating the real possible types. I understand PRs like this exist to improve that situation.

in the example, I think the conflation of types inside floated_admin_avatar() is more of the problem than the if ( $avatar ) (though I would agree it’s also a problem). it would seem more robust to perform the checks within floated_admin_avatar() and return a positive signal of failure rather than an implicit behavior, e.g. string|null.

in this particular case I mis-identified the type as being wrong, so it’s not important to focus on it. that was my mistake.

*/
public function floated_admin_avatar( $name, $comment_id ) {
$comment = get_comment( $comment_id );
Expand Down
8 changes: 8 additions & 0 deletions src/wp-admin/includes/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,8 @@
* @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 = '' ) {

Expand Down Expand Up @@ -1348,6 +1350,8 @@
*
* @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.
Expand Down Expand Up @@ -1637,6 +1641,8 @@
* @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;
Expand Down Expand Up @@ -2895,7 +2901,7 @@
'paged' => false,
)
)
) . '"' . $class . '>' . sprintf( translate_nooped_plural( $label[2], $num_posts[ $mime_type ] ), '<span id="' . $mime_type . '-counter">' . number_format_i18n( $num_posts[ $mime_type ] ) . '</span>' ) . '</a>';

Check warning on line 2904 in src/wp-admin/includes/media.php

View workflow job for this annotation

GitHub Actions / PHP static analysis / Run PHP static analysis

Parameter #1 $nooped_plural of function translate_nooped_plural expects array{singular: literal-string, plural: literal-string, context: literal-string|null, domain: literal-string|null, ...}, array given.
}
/**
* Filters the media upload mime type list items.
Expand Down Expand Up @@ -3013,6 +3019,8 @@
*
* @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 */
Expand Down
2 changes: 2 additions & 0 deletions src/wp-admin/includes/ms.php
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,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 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
Expand Down
28 changes: 28 additions & 0 deletions src/wp-admin/includes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1399,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 non-falsy-string $menu_slug
*/
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;
Expand Down Expand Up @@ -1494,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 non-falsy-string $menu_slug
*/
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,
Expand Down Expand Up @@ -1607,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 non-falsy-string $menu_slug
*/
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 );
Expand All @@ -1631,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 non-falsy-string $menu_slug
*/
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 );
Expand All @@ -1655,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 non-falsy-string $menu_slug
*/
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 );
Expand All @@ -1679,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 non-falsy-string $menu_slug
*/
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 );
Expand All @@ -1703,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 non-falsy-string $menu_slug
*/
function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
if ( current_user_can( 'edit_users' ) ) {
Expand Down Expand Up @@ -1732,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 non-falsy-string $menu_slug
*/
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 );
Expand All @@ -1756,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 non-falsy-string $menu_slug
*/
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 );
Expand All @@ -1780,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 non-falsy-string $menu_slug
*/
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 );
Expand All @@ -1804,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 non-falsy-string $menu_slug
*/
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 );
Expand All @@ -1828,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 non-falsy-string $menu_slug
*/
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 );
Expand All @@ -1852,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 non-falsy-string $menu_slug
*/
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 );
Expand Down Expand Up @@ -2147,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;
Expand Down
2 changes: 2 additions & 0 deletions src/wp-admin/includes/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -2654,6 +2654,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 ) ) {
Expand Down
2 changes: 2 additions & 0 deletions src/wp-admin/includes/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ";
Expand Down
4 changes: 4 additions & 0 deletions src/wp-includes/abilities-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) ) {
Expand Down Expand Up @@ -652,6 +654,8 @@ function _wp_get_abilities_match_meta( array $meta, array $conditions ): bool {
* @type array<string, mixed> $meta Optional. Additional metadata for the ability category.
* }
* @return WP_Ability_Category|null The registered ability category instance on success, `null` on failure.
*
* @phpstan-param lowercase-string&non-empty-string $slug
*/
function wp_register_ability_category( string $slug, array $args ): ?WP_Ability_Category {
if ( ! doing_action( 'wp_abilities_api_categories_init' ) ) {
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/abilities-api/class-wp-abilities-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ final class WP_Abilities_Registry {
* @type string $ability_class Optional. Custom class to instantiate instead of WP_Ability.
* }
* @return WP_Ability|null The registered ability instance on success, null on failure.
*
* @phpstan-param lowercase-string&non-falsy-string $name
*/
public function register( string $name, array $args ): ?WP_Ability {
if ( ! preg_match( '/^[a-z0-9-]+\/[a-z0-9-]+$/', $name ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ final class WP_Ability_Categories_Registry {
* @type array<string, mixed> $meta Optional. Additional metadata for the ability category.
* }
* @return WP_Ability_Category|null The registered ability category instance on success, null on failure.
*
* @phpstan-param lowercase-string&non-empty-string $slug
*/
public function register( string $slug, array $args ): ?WP_Ability_Category {
if ( $this->is_registered( $slug ) ) {
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/block-bindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
* @type string[] $uses_context Optional. Array of values to add to block `uses_context` needed by the source.
* }
* @return WP_Block_Bindings_Source|false Source when the registration was successful, or `false` on failure.
*
* @phpstan-param lowercase-string&non-falsy-string $source_name
*/
function register_block_bindings_source( string $source_name, array $source_properties ) {
return WP_Block_Bindings_Registry::get_instance()->register( $source_name, $source_properties );
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/block-supports/elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -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-' );
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/block-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ function _resolve_template_for_new_post( $wp_query ) {
* @type string $plugin Optional. Slug of the plugin that registers the template.
* }
* @return WP_Block_Template|WP_Error The registered template object on success, WP_Error object on failure.
*
* @phpstan-param lowercase-string&non-falsy-string $template_name
*/
function register_block_template( $template_name, $args = array() ) {
return WP_Block_Templates_Registry::get_instance()->register( $template_name, $args );
Expand Down
5 changes: 5 additions & 0 deletions src/wp-includes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ function register_block_type( $block_type, $args = array() ) {
return register_block_type_from_metadata( $block_type, $args );
}

/** @var (lowercase-string&non-falsy-string)|WP_Block_Type $block_type A string that is not a path to block metadata should be a block type name. */
return WP_Block_Type_Registry::get_instance()->register( $block_type, $args );
}

Expand Down Expand Up @@ -3084,6 +3085,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(
Expand Down Expand Up @@ -3184,6 +3187,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(
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/class-wp-ajax-response.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/class-wp-block-bindings-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ final class WP_Block_Bindings_Registry {
* @type string[] $uses_context Optional. Array of values to add to block `uses_context` needed by the source.
* }
* @return WP_Block_Bindings_Source|false Source when the registration was successful, or `false` on failure.
*
* @phpstan-param lowercase-string&non-falsy-string $source_name
*/
public function register( string $source_name, array $source_properties ) {
if ( ! is_string( $source_name ) ) {
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/class-wp-block-templates-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ final class WP_Block_Templates_Registry {
* @param string $template_name Template name including namespace.
* @param array $args Optional. Array of template arguments.
* @return WP_Block_Template|WP_Error The registered template on success, or WP_Error on failure.
*
* @phpstan-param lowercase-string&non-falsy-string $template_name
*/
public function register( $template_name, $args = array() ) {

Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/class-wp-block-type-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ final class WP_Block_Type_Registry {
* of `WP_Block_Type`. See WP_Block_Type::__construct() for information
* on accepted arguments. Default empty array.
* @return WP_Block_Type|false The registered block type on success, or false on failure.
*
* @phpstan-param (lowercase-string&non-falsy-string)|WP_Block_Type $name
*/
public function register( $name, $args = array() ) {
$block_type = null;
Expand Down
1 change: 1 addition & 0 deletions src/wp-includes/class-wp-connector-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ final class WP_Connector_Registry {
* }
* @return array|null The registered connector data on success, null on failure.
*
* @phpstan-param lowercase-string&non-empty-string $id
* @phpstan-param array{
* name: non-empty-string,
* description?: string,
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/class-wp-dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,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 ) {
/*
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/class-wp-icon-collections-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class WP_Icon_Collections_Registry {
* via {@see wp_get_icon()}. Default true.
* }
* @return bool True if the collection was registered successfully, false otherwise.
*
* @phpstan-param lowercase-string&non-empty-string $collection_slug
*/
public function register( $collection_slug, $collection_properties ) {
if ( ! isset( $collection_slug ) || ! is_string( $collection_slug ) ) {
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/class-wp-icons-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ protected function __construct() {}
* `get_registered_icons()` alongside the name and label.
* }
* @return bool True if the icon was registered with success and false otherwise.
*
* @phpstan-param lowercase-string&non-falsy-string $icon_name
*/
public function register( $icon_name, $icon_properties ) {
if ( ! isset( $icon_name ) || ! is_string( $icon_name ) ) {
Expand Down
Loading
Loading