Skip to content

Build/QA: Retire nullCoalesce.property baseline - #13982

Open
huzaifaalmesbah wants to merge 2 commits into
WordPress:trunkfrom
huzaifaalmesbah:phpstan/retire-null-coalesce-property
Open

huzaifaalmesbah wants to merge 2 commits into
WordPress:trunkfrom
huzaifaalmesbah:phpstan/retire-null-coalesce-property

Conversation

@huzaifaalmesbah

@huzaifaalmesbah huzaifaalmesbah commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

Description

This PR resolves all occurrences of nullCoalesce.property and completely retires tests/phpstan/baselines/nullCoalesce.property.neon:

  1. src/wp-includes/class-wp-locale.php:
    $this->word_count_type is uninitialized / null until init() calls get_word_count_type(), which uses $this->word_count_type ?? _x( 'words', ... ) to fall back to the localized word count translation. Updating the property's PHPDoc @var tag from string to string|null accurately documents its lifecycle and resolves the nullCoalesce.property static analysis error without breaking locale-specific word/character counting.

  2. src/wp-includes/general-template.php:
    WP_Query::$max_num_pages is non-nullable (int). Adjusted $wp_query->max_num_pages ?? 1 to ! empty( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1 to preserve correct fallback when max_num_pages is 0.

  3. src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php:
    WP_Post_Type::$template is initialized as array(). Simplified $post_type->template ?? array() to $post_type->template.

Testing Instructions

  1. Run composer phpstan locally to verify 0 errors.
  2. Run locale and formatting unit tests:
    npm run test:php -- --filter=Tests_Formatting_wpTrimWords
    npm run test:php -- --filter=paginate_links
  3. Run PHPCS to verify coding standards:
    vendor/bin/phpcs src/wp-includes/class-wp-locale.php src/wp-includes/general-template.php src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php

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

Use of AI Tools

AI assistance: Yes
Tool(s): Google Antigravity
Model(s): Gemini 3.8 Flash
Used for: Assisting with static analysis archaeology, tests, and diff preparation; all code and tests were manually reviewed, verified, and locally run by me.

@github-actions

github-actions Bot commented Oct 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. 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 huzaifaalmesbah.

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

@github-actions

github-actions Bot commented Oct 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.

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.

1 participant