Skip to content

Code Quality:Remove resolved identical.alwaysFalse PHPStan baseline: - #13782

Open
arshidkv12 wants to merge 2 commits into
WordPress:trunkfrom
arshidkv12:identical.alwaysFalse
Open

arshidkv12 wants to merge 2 commits into
WordPress:trunkfrom
arshidkv12:identical.alwaysFalse

Conversation

@arshidkv12

@arshidkv12 arshidkv12 commented Sep 27, 2026 •

Copy link
Copy Markdown

In 66739

Remove resolved identical.alwaysFalse PHPStan baseline

Remove the identical.alwaysFalse PHPStan baseline and fix the
underlying issues that it was suppressing.

  • Remove the unreachable update-selected admin notice in plugins.php. See r56573

  • Simplify the HTML processor exception handling since bookmark_token()
    sets last_error before throwing. r61755

  • Use PHP_INT_SIZE in wp_rand() to correctly detect 32-bit environments. See r34981

  • Remove the redundant false === $value check in
    WP_REST_Users_Controller::check_reassign(). See r39426

  • Remove the now-unused identical.alwaysFalse baseline from the PHPStan
    configuration.

Use of AI Tools

AI assistance: Yes
Tool(s): ChatGPT
Model(s): GPT-5.6 Luna
Used for: Reviewing PHPStan findings and discussing possible fixes. The final implementation and changes were reviewed and made by me.

@github-actions

github-actions Bot commented Sep 27, 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 arshidkv12, mukesh27, westonruter.

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 or WordPress.org 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.

@github-actions

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 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for working on this! I checked each change against the surrounding code. All four source changes keep behavior the same, and CI is green. A few notes:

1. plugins.php: removing the update-selected notice ✅
The notice could never run. case 'update-selected': always ends with exit;, so execution never reaches the elseif further down. Safe to remove.

2. class-wp-html-processor.php: simplifying the catch ✅ (nit)
bookmark_token() throws in only one place, and it always sets last_error = ERROR_EXCEEDED_MAX_BOOKMARKS first, so returning false directly is equivalent.

  • Nit: the catch now ignores which exception it got. If bookmark_token() ever throws for another reason, that error will quietly become return false. A short comment would help future readers, e.g. // bookmark_token() only throws after setting ERROR_EXCEEDED_MAX_BOOKMARKS.
  • $e needs to stay, since a catch without a variable requires PHP 8.0.
  • The similar catch in step()'s outer try block should stay as it is. That block can throw other exceptions, so its check does real work.

3. pluggable.php: wp_rand() ⚠️
3000000000 === 2147483647 wasn't really dead code. It was a runtime check for broken 32-bit builds (Entropy PHP), where the literal gets cut down to PHP_INT_MAX. PHPStan flags it only because it analyzes on 64-bit. PHP_INT_SIZE === 4 still gives the right result on both normal and broken 32-bit builds, so the change is fine. Two suggestions:

  • Please update the comment above this line. It still describes the truncation check, which the new condition no longer performs.
  • Could we simplify further to $max_random_number = 4294967295; // 0xffffffff? That truncation bug came from the PHP 5 era. Core now needs PHP 7.4+, where a literal that's too big for an int always becomes a float, so the ternary and the comment could both go. If you'd rather keep the smaller change, PHP_INT_SIZE === 4 is fine and matches existing usage in wp-includes/update.php.

4. WP_REST_Users_Controller::check_reassign() ✅
empty( false ) is already true, so false === $value added nothing.

5. Baseline removal ✅
The include and the baseline file are both removed, and the PHPStan job passes.

🤖 Comment by Claude Opus 5.5

Comment thread phpstan.neon.dist Outdated
- tests/phpstan/baselines/function.impossibleType.neon
- tests/phpstan/baselines/function.resultUnused.neon
- tests/phpstan/baselines/greaterOrEqual.alwaysTrue.neon
- tests/phpstan/baselines/identical.alwaysFalse.neon

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🤖 Comment by Claude Opus 5.5 (medium effort)

With the commit of r65566, the baseline files are now no longer listed out one-by-one in the phpstan.neon.dist. This change can be reverted and the baselines can be re-generated with the merge from trunk. The conflict on the deleted baseline file comes from the same commit updating its header; keeping the deletion, or re-generating the baselines, resolves it.

@arshidkv12
arshidkv12 force-pushed the identical.alwaysFalse branch from c3539a9 to 5de0787 Compare November 19, 2026 15:17
@github-actions

This comment has been minimized.

@arshidkv12

Copy link
Copy Markdown
Author

I think, already fixed by r65566.
Can I close it?

@mukeshpanchal27

Copy link
Copy Markdown
Member

I think, already fixed by r65566. Can I close it?

No. I don't see the changes in trunk.

@westonruter

Copy link
Copy Markdown
Member

There are PHPStan errors being reported.

phpstan:
name: PHP static analysis
uses: ./.github/workflows/reusable-phpstan-static-analysis-v1.yml
uses: ./.github/workflows/reusable-phpstan-static-analysis-v2.yml
@arshidkv12
arshidkv12 force-pushed the identical.alwaysFalse branch from f794568 to 5de0787 Compare November 21, 2026 04:23
@arshidkv12
arshidkv12 force-pushed the identical.alwaysFalse branch from a8d2b6a to 59dd1a6 Compare November 21, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants