Commit bccee1022d for wordpress.org

commit bccee1022dc0f0895b4119d3ac68b4f869ce5dc9
Author: westonruter <westonruter@git.wordpress.org>
Date:   Wed Nov 25 17:44:41 2026 +0000

    Code Quality: Fix the `$args` types of `wp_get_recent_posts()`.

    The `$args` parameter was documented as accepting only an array, even though a deprecated integer number of posts is still accepted. PHPStan therefore concluded that the deprecated branch could never run, and reported the value passed to `absint()` there as an unresolvable type. Documenting the integer form, as was done for `wp_get_typography_font_size_value()` in r64163, empties the `argument.unresolvableType` baseline, so it is removed.

    For static analysis the integer is narrowed to `positive-int`, since `absint()` silently turns a negative number into a positive count and `0` falls back to the `posts_per_page` option. A hash now documents the arguments whose defaults differ from those of `get_posts()`.

    At level 10 the parsed arguments could not be passed to `get_posts()`, because the inline `@var` typed only `fields`. It now types the keys that `get_posts()` documents. Instead of being asserted to be `null`, `fields` is limited to `''` or `'all'`, since a caller asking for IDs would make `get_object_vars()` throw a `TypeError` with the default `ARRAY_A` output. The `include` and `exclude` defaults become empty arrays to match their documented type, which has no runtime effect.

    Developed in https://github.com/WordPress/wordpress-develop/pull/15450.
    Follow-up to r62648, r63024, r64163.

    Props mukesh27, westonruter.
    See #66739.

    Built from https://develop.svn.wordpress.org/trunk@65783


    git-svn-id: http://core.svn.wordpress.org/trunk@64812 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-includes/post.php b/wp-includes/post.php
index 3511fbfc81..6d42c97836 100644
--- a/wp-includes/post.php
+++ b/wp-includes/post.php
@@ -4708,13 +4708,37 @@ function wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array(
  *
  * @see get_posts()
  *
- * @param array  $args   Optional. Arguments to retrieve posts. Default empty array.
- * @param string $output Optional. The required return type. One of OBJECT or ARRAY_A, which
- *                       correspond to a WP_Post object or an associative array, respectively.
- *                       Default ARRAY_A.
+ * @param array|int $args {
+ *     Optional. Arguments to retrieve posts. See {@see get_posts()} and
+ *     {@see WP_Query::parse_query()} for all available arguments. Those listed here
+ *     have defaults that differ. Passing an integer number of posts is deprecated
+ *     since 3.1.0. Default empty array.
+ *
+ *     @type int             $numberposts Total number of posts to retrieve. Accepts -1 for all.
+ *                                        Default 10.
+ *     @type int             $offset      The number of posts to offset before retrieval. Default 0.
+ *     @type string|array    $orderby     Sort retrieved posts by parameter. Default 'post_date'.
+ *     @type string|string[] $post_status A post status (string) or array of post statuses.
+ *                                        Default 'draft, publish, future, pending, private'.
+ * }
+ * @param string    $output Optional. The required return type. One of OBJECT or ARRAY_A, which
+ *                          correspond to a WP_Post object or an associative array, respectively.
+ *                          Default ARRAY_A.
  * @return array|false Array of recent posts, where the type of each element is determined
  *                     by the `$output` parameter. Empty array on failure.
  *
+ * @phpstan-param positive-int|array{
+ *     numberposts?: int,
+ *     offset?: int,
+ *     orderby?: string|array<mixed>,
+ *     post_status?: string|string[],
+ *     category?: int|string,
+ *     include?: int[],
+ *     exclude?: int[],
+ *     suppress_filters?: bool,
+ *     fields?: ''|'all',
+ *     ...
+ * } $args
  * @phpstan-param 'OBJECT'|'ARRAY_A' $output
  * @phpstan-return (
  *     $output is 'ARRAY_A' ? array<int, non-empty-array<string, mixed>> : WP_Post[]|false
@@ -4734,8 +4758,8 @@ function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) {
 		'category'         => 0,
 		'orderby'          => 'post_date',
 		'order'            => 'DESC',
-		'include'          => '',
-		'exclude'          => '',
+		'include'          => array(),
+		'exclude'          => array(),
 		'meta_key'         => '',
 		'meta_value'       => '',
 		'post_type'        => 'post',
@@ -4743,7 +4767,7 @@ function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) {
 		'suppress_filters' => true,
 	);

-	/** @var array{ fields: null, ... } $parsed_args */
+	/** @var array{ numberposts: int, category: int|string, include: int[], exclude: int[], suppress_filters: bool, fields?: ''|'all', ... } $parsed_args */
 	$parsed_args = wp_parse_args( $args, $defaults );

 	$results = get_posts( $parsed_args );
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 8c43ba3d1b..1d7064c2fe 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.3-alpha-65781';
+$wp_version = '7.3-alpha-65783';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.