Repository navigation
Code Quality:: Fix the argument.unresolvableType PHPStan error and remove the baseline - #15450
mukeshpanchal27 wants to merge 1 commit into
Conversation
…()`. `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>
|
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: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
argument.unresolvableType PHPStan error and remove the baselineargument.unresolvableType PHPStan error and remove the baseline
There was a problem hiding this comment.
🟢 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
$argsasarray|intand 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
This PR fixes the only
argument.unresolvableTypeerror and deletestests/phpstan/baselines/argument.unresolvableType.neon. There is no runtime change.The error
wp_get_recent_posts()still accepts an integer number of posts, which has been deprecated since 3.1.0:The
@paramtag documented$argsasarrayonly. PHPStan trusts the docblock, so it concluded thatis_numeric( $args )can never be true. Inside that branch,$argshas no possible type, and theabsint()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
$argsasarray|intand 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 phpstanreports no errors.php -lpasses onsrc/wp-includes/post.php.src/wp-includes/post.phpas ontrunk.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