From b8ffd73debd51df7c799c2886a5719e0c50aadcb Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Wed, 4 Nov 2026 14:14:34 +0530 Subject: [PATCH] Docs: Document the deprecated integer `$args` in `wp_get_recent_posts()`. `wp_get_recent_posts()` still accepts an integer number of posts, which has been deprecated since 3.1.0. The `@param` tag documented `$args` as `array` only, so PHPStan concluded that `is_numeric( $args )` can never be true. It then reported that the `absint()` call in that branch receives an unresolvable type. This change documents `$args` as `array|int`, states the deprecation in its description, deletes the now empty `argument.unresolvableType` baseline, and removes its `includes` line from `phpstan.neon.dist`. There is no runtime change. See #65817. Co-Authored-By: Claude Opus 5.5 --- phpstan.neon.dist | 1 - src/wp-includes/post.php | 9 ++++--- .../baselines/argument.unresolvableType.neon | 25 ------------------- 3 files changed, 5 insertions(+), 30 deletions(-) delete mode 100644 tests/phpstan/baselines/argument.unresolvableType.neon diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 655bb9bbc807c..0af28d696b2af 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -23,7 +23,6 @@ includes: # and the list between the markers. Do not edit that list by hand. # phpstan:baselines start - tests/phpstan/baselines/argument.type.neon - - tests/phpstan/baselines/argument.unresolvableType.neon - tests/phpstan/baselines/assign.propertyType.neon - tests/phpstan/baselines/binaryOp.invalid.neon - tests/phpstan/baselines/booleanAnd.alwaysFalse.neon diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 5806d879f1c5e..e186de3c5ce1c 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -4707,10 +4707,11 @@ 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. Passing an integer number + * of posts is deprecated since 3.1.0. 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. * @return array|false Array of recent posts, where the type of each element is determined * by the `$output` parameter. Empty array on failure. * diff --git a/tests/phpstan/baselines/argument.unresolvableType.neon b/tests/phpstan/baselines/argument.unresolvableType.neon deleted file mode 100644 index 3e8cdcb76c85d..0000000000000 --- a/tests/phpstan/baselines/argument.unresolvableType.neon +++ /dev/null @@ -1,25 +0,0 @@ -# PHPStan baseline for the `argument.unresolvableType` errors in WordPress core. -# -# https://phpstan.org/error-identifiers/argument.unresolvableType -# -# Each entry is scoped to a single file and carries an exact occurrence count, -# so that a new instance is reported as a new error rather than being absorbed -# silently. Fixing an occurrence therefore means decrementing or removing its -# entry here as part of the same change. -# -# The goal is to empty this file and delete it, along with the `includes` entry -# for it in phpstan.neon.dist. -# -# Generated by `composer phpstan:baselines`. Do not edit by hand; regenerate with -# -# composer phpstan:baselines -- --identifier=argument.unresolvableType -# -# which reruns the analysis with this file suppressed so the errors surface again. - -parameters: - ignoreErrors: - - - message: '#^Parameter \#1 \$maybeint of function absint contains unresolvable type\.$#' - identifier: argument.unresolvableType - count: 1 - path: ../../../src/wp-includes/post.php