Skip to content

Code Quality:: Fix the argument.unresolvableType PHPStan error and remove the baseline - #15450

Open
mukeshpanchal27 wants to merge 1 commit into
WordPress:trunkfrom
mukeshpanchal27:fix/argument-unresolvabletype-baseline
Open

mukeshpanchal27 wants to merge 1 commit into
WordPress:trunkfrom
mukeshpanchal27:fix/argument-unresolvabletype-baseline

Conversation

@mukeshpanchal27

Copy link
Copy Markdown
Member

This PR fixes the only argument.unresolvableType error and deletes tests/phpstan/baselines/argument.unresolvableType.neon. There is no runtime change.

The error

src/wp-includes/post.php:4726
Parameter #1 $maybeint of function absint contains unresolvable type.

wp_get_recent_posts() still accepts an integer number of posts, which has been deprecated since 3.1.0:

if ( is_numeric( $args ) ) {
	_deprecated_argument( __FUNCTION__, '3.1.0', ... );
	$args = array( 'numberposts' => absint( $args ) );
}

The @param tag documented $args as array only. PHPStan trusts the docblock, so it concluded that is_numeric( $args ) can never be true. Inside that branch, $args has no possible type, and the absint() call receives an unresolvable type.

This error is not a false positive. The docblock was incomplete, because it left out a form that the function still accepts.

The fix

This PR documents $args as array|int and states the deprecation in the description. It does not change the code, because plugins can still pass an integer. No caller in core passes one.

Testing

  • composer phpstan reports no errors.
  • php -l passes on src/wp-includes/post.php.
  • PHPCS reports the same warnings on src/wp-includes/post.php as on trunk.

Trac ticket: https://core.trac.wordpress.org/ticket/65817

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Finding the cause of the error, editing the docblock and baseline, and drafting the PR. I reviewed the changes.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

🤖 Generated with Claude Code

…()`.

`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 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props mukesh27.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@mukeshpanchal27 mukeshpanchal27 self-assigned this Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@mukeshpanchal27 mukeshpanchal27 changed the title Docs: Fix the argument.unresolvableType PHPStan error and remove the baseline Code Quality:: Fix the argument.unresolvableType PHPStan error and remove the baseline Nov 4, 2026
@mukeshpanchal27
mukeshpanchal27 requested a lite review from Copilot November 4, 2026 08:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain, and the documented supported argument type aligns with removing the obsolete PHPStan baseline and configuration entry.

No open issues 🎉

What changed in this PR

This pull request fixes the remaining PHPStan argument.unresolvableType error by documenting the deprecated integer form accepted by wp_get_recent_posts(). Runtime behavior is unchanged.

Changes:

  • Documents $args as array|int and notes the deprecated integer usage.
  • Removes the resolved PHPStan baseline.
  • Removes the deleted baseline from phpstan.neon.dist.
File Description
tests/​phpstan/​baselines/​argument.unresolvableType.neon Removes the obsolete PHPStan error baseline.
src/​wp-includes/​post.php Documents the supported deprecated integer argument form.
phpstan.neon.dist Removes the deleted baseline from the PHPStan includes.

Review effort: Lite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants