diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index 6719126ea4e23..580ba2cb751ce 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -4160,6 +4160,7 @@ function adjacent_image_link( $prev = true, $size = 'thumbnail', $text = false ) * or 'objects' to return an array of taxonomy objects. * Default is 'names'. * @return string[]|WP_Taxonomy[] List of taxonomies or taxonomy names. Empty array on failure. + * @phpstan-return ( $output is 'names' ? list : array ) */ function get_attachment_taxonomies( $attachment, $output = 'names' ) { if ( is_int( $attachment ) ) { @@ -4204,7 +4205,9 @@ function get_attachment_taxonomies( $attachment, $output = 'names' ) { } if ( 'names' === $output ) { - $taxonomies = array_unique( $taxonomies ); + /** @var non-falsy-string[] $taxonomies */ + $unique_taxonomies = array_values( array_unique( $taxonomies ) ); + $taxonomies = $unique_taxonomies; } return $taxonomies; @@ -4222,6 +4225,7 @@ function get_attachment_taxonomies( $attachment, $output = 'names' ) { * @param string $output Optional. The type of taxonomy output to return. Accepts 'names' or 'objects'. * Default 'names'. * @return string[]|WP_Taxonomy[] Array of names or objects of registered taxonomies for attachments. + * @phpstan-return ( $output is 'names' ? list : array ) */ function get_taxonomies_for_attachments( $output = 'names' ) { $taxonomies = array(); diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 49ab472d37184..2ac3b18212c0d 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -1575,6 +1575,7 @@ function get_post_status_object( $post_status ) { * from the array needs to match; 'and' means all elements must match. * Default 'and'. * @return string[]|stdClass[] A list of post status names or objects. + * @phpstan-return ( $output is 'names' ? array : array ) */ function get_post_stati( $args = array(), $output = 'names', $operator = 'and' ) { global $wp_post_statuses; diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index 29317f0a8bf9b..533a725b4707b 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -278,6 +278,7 @@ function create_initial_taxonomies() { * one element from the array needs to match; 'and' means all elements must match. * Default 'and'. * @return string[]|WP_Taxonomy[] An array of taxonomy names or objects. + * @phpstan-return ( $output is 'names' ? array : array ) */ function get_taxonomies( $args = array(), $output = 'names', $operator = 'and' ) { global $wp_taxonomies; @@ -301,12 +302,13 @@ function get_taxonomies( $args = array(), $output = 'names', $operator = 'and' ) * * @since 2.3.0 * - * @global WP_Taxonomy[] $wp_taxonomies The registered taxonomies. + * @global array $wp_taxonomies The registered taxonomies. * * @param string|string[]|WP_Post $object_type Name of the type of taxonomy object, or an object (row from posts). * @param string $output Optional. The type of output to return in the array. Accepts either * 'names' or 'objects'. Default 'names'. * @return string[]|WP_Taxonomy[] The names or objects of all taxonomies of `$object_type`. + * @phpstan-return ( $output is 'names' ? list : array ) */ function get_object_taxonomies( $object_type, $output = 'names' ) { global $wp_taxonomies;