Skip to content

Build/Test Tools: Use the null coalescing assignment operator in the test suite - #13511

Closed
Soean wants to merge 1 commit into
WordPress:trunkfrom
Soean:tests/null-coalescing-assignment
Closed

Soean wants to merge 1 commit into
WordPress:trunkfrom
Soean:tests/null-coalescing-assignment

Conversation

@Soean

@Soean Soean commented Sep 14, 2026

Copy link
Copy Markdown
Member

Replaces the "assign a default only if not already set" guard blocks in the PHPUnit test suite, the shared test infrastructure and the PHPStan hook docblock helper with the null coalescing assignment operator (??=).

Scope

Each touched file is converted completely: every guard that ??= can express is converted, so no file is left half-modernized.

The same pattern exists throughout src/; that is left for separate follow-ups on the same ticket so each one stays reviewable. This PR is test-only, which makes it independent of the others in the series.

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


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.

@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. You can also manually ask me to refresh this list by adding the props-bot label.

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

Props soean.

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

@westonruter
westonruter requested a lite review from Copilot September 15, 2026 06:08

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

LGTM

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 unresolved review comments remain, and all reviewed changes are approval-ready.

Pull request overview

This test-only PR modernizes default initialization with PHP’s null coalescing assignment operator (??=).

Changes:

  • Updates PHPUnit tests and shared infrastructure.
  • Modernizes PHPStan hook documentation caching.
  • Leaves production code unchanged.
File summaries
File Description
tests/phpunit/tests/wp-token-map/wpTokenMap.php Modernizes token-map caching.
tests/phpunit/tests/url.php Modernizes global post initialization.
tests/phpunit/tests/rest-api/rest-schema-validation.php Modernizes schema defaults.
tests/phpunit/tests/fonts/font-face/wp-font-face-tests-dataset.php Modernizes dataset caching.
tests/phpunit/tests/blocks/registerCoreBlockStyleHandles.php Modernizes block style defaults.
tests/phpunit/tests/blocks/register.php Modernizes block metadata defaults.
tests/phpunit/tests/admin/plugin-dependencies/base.php Modernizes reflection caching.
tests/phpunit/includes/utils.php Modernizes parser and filter defaults.
tests/phpunit/includes/factory/class-wp-unittest-factory-for-thing.php Modernizes factory defaults.
tests/phpunit/includes/class-wp-test-stream.php Modernizes stream data initialization.
tests/phpunit/includes/class-wp-phpunit-timing-metrics.php Modernizes timing fallback logic.
tests/phpunit/includes/abstract-testcase.php Modernizes URL query initialization.
tests/phpstan/HookDocBlock.php Modernizes hook documentation caches.
Review details
  • Files reviewed: 13/13 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@lancewillett lancewillett moved this from Backlog to In review in WordPress Project Build Tooling Sep 15, 2026
wporg-sync pushed a commit that referenced this pull request Sep 15, 2026
…test suite.

Replaces the “assign a default only if not already set” guard blocks in the PHPUnit test suite, the shared test infrastructure and the PHPStan hook docblock helper with the null coalescing assignment operator (`??=`).

Developed in #13511.

Props Soean, westonruter.
See #65823.

git-svn-id: https://develop.svn.wordpress.org/trunk@63633 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Sep 15, 2026
…test suite.

Replaces the “assign a default only if not already set” guard blocks in the PHPUnit test suite, the shared test infrastructure and the PHPStan hook docblock helper with the null coalescing assignment operator (`??=`).

Developed in WordPress/wordpress-develop#13511.

Props Soean, westonruter.
See #65823.
Built from https://develop.svn.wordpress.org/trunk@63633


git-svn-id: http://core.svn.wordpress.org/trunk@62808 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@SergeyBiryukov

Copy link
Copy Markdown
Member

Thanks for the PR! Merged in r63633.

@Soean
Soean deleted the tests/null-coalescing-assignment branch September 16, 2026 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

5 participants