Skip to content

Build/Test Tools: Update PHPStan to 2.3.6 and the PHPUnit extension to 2.1.2 - #16042

Closed
westonruter wants to merge 2 commits into
WordPress:trunkfrom
westonruter:update-phpstan
Closed

westonruter wants to merge 2 commits into
WordPress:trunkfrom
westonruter:update-phpstan

Conversation

@westonruter

@westonruter westonruter commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

✅ Committed in r65537 (55885f6).


Updates PHPStan and its extensions to their latest releases:

  • phpstan/phpstan 2.3.5 → 2.3.6
    • Full support for PHP 8.6, including partial function application.
    • Float range types, such as float<0, 1.5>, finite-float, and positive-float.
    • When only part of a project is analyzed, such as a single directory or a list of files, ignoreErrors entries for code outside the analysis are no longer reported as unmatched.
    • The result cache tracks which symbols each file looked up, so a new class or function reanalyzes only the files that asked about it, rather than every file with errors (baselined ones included).
    • Many fixes to type narrowing (loose comparisons, isset(), count(), match (true)), fixes to inline @phpstan-ignore comments in traits, and speedups such as baseline matching in time linear in the baseline's size.
    • Baselines regenerated for what this changes in core: three variable.undefined errors are no longer reported, the message of an offsetAccess.notFound error now names the range of the offset, and the two assign.propertyType errors for WP_Query::$posts are each reported for a second assignment as well. Those are the ??= assignments in WP_Query::get_posts() for the 'ids' and 'id=>parent' fields, which PHPStan now checks by the type of the right-hand side alone rather than of the whole expression (Pass only the right-hand side of ??= as the written expression to PropertyAssignNode and VariableAssignNode phpstan/phpstan-src#6943).
  • phpstan/phpstan-phpunit 2.1.1 → 2.1.2
    • Narrows types after assertGreaterThan() and assertLessThan().
    • Reports a data provider that provides no data sets.
    • Changes nothing that PHPStan reports for core, so no baselines change.
  • phpstan/phpstan-strict-rules stays at 2.1.1, which is already the latest.

This is split out of #16021, which relies on PHPStan 2.3.6.

Companion Gutenberg PR: WordPress/gutenberg#86922

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 (medium effort)
Used for: Updating the dependencies, regenerating and checking the baselines, and drafting this description; directed and reviewed by me.


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.

westonruter and others added 2 commits November 16, 2026 12:48
When only part of the project is analyzed, such as a single directory or a list of files, PHPStan 2.3.6 no longer reports `ignoreErrors` entries as unmatched merely because what they ignore lies outside the analysis. The result cache also now tracks the symbols each file looked up, rather than reanalyzing every file with errors on each run. The release adds full support for PHP 8.6 and float range types, along with many fixes to type narrowing.

The baselines are regenerated for what the update changes in the analysis: three `variable.undefined` errors are no longer reported, the message of an `offsetAccess.notFound` error now names the range of the offset, and the two `assign.propertyType` errors for `WP_Query::$posts` are each reported for a second assignment as well.

Co-Authored-By: Claude Opus 5.5 (medium effort) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tnky3Grhn8Rv7MidzhrtXU
Claude-Code-Session-Id: d102d8d5-ffa7-4c14-add5-1e05d41fe751
The extension now narrows types after `assertGreaterThan()` and `assertLessThan()`, and reports a data provider that provides no data sets. Neither changes what PHPStan reports for core, so the baselines are unchanged.

Co-Authored-By: Claude Opus 5.5 (medium effort) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tnky3Grhn8Rv7MidzhrtXU
Claude-Code-Session-Id: d102d8d5-ffa7-4c14-add5-1e05d41fe751
@westonruter
westonruter marked this pull request as ready for review November 16, 2026 20:52
@github-actions

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 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.

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 are identified, and the changes are limited to the PHPStan toolchain upgrade and corresponding regenerated baseline adjustments.

No open issues 🎉

What changed in this PR

Updates WordPress core’s PHPStan tooling to PHPStan 2.3.6 and the PHPUnit extension 2.1.2, with regenerated static-analysis baselines for diagnostics changed by the upgrade.

Changes:

  • Updates the pinned PHPStan and PHPStan PHPUnit extension versions.
  • Removes obsolete undefined-variable baseline entries.
  • Adjusts baseline messages and occurrence counts for revised PHPStan diagnostics.
File Description
tests/​phpstan/​baselines/​variable.undefined.neon Removes undefined-variable suppressions that are no longer reported by PHPStan 2.3.6.
tests/​phpstan/​baselines/​offsetAccess.notFound.neon Updates the diagnostic message to reflect PHPStan’s refined float-range output.
tests/​phpstan/​baselines/​assign.propertyType.neon Adjusts occurrence counts for additional assignments reported by PHPStan.
composer.json Updates the PHPStan and PHPStan PHPUnit extension development dependencies.

Review effort: Lite

wporg-sync pushed a commit that referenced this pull request Nov 16, 2026
This also updates `phpstan/phpstan-phpunit` to 2.1.2, and regenerates the baselines for the errors PHPStan now reports differently.

Developed in #16042.
Follow-up to r65078, r65310.

See #65817.


git-svn-id: https://develop.svn.wordpress.org/trunk@65537 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 16, 2026
This also updates `phpstan/phpstan-phpunit` to 2.1.2, and regenerates the baselines for the errors PHPStan now reports differently.

Developed in WordPress/wordpress-develop#16042.
Follow-up to r65078, r65310.

See #65817.

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


git-svn-id: http://core.svn.wordpress.org/trunk@64610 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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