Skip to content

Code Quality: Resolve method.notFound PHPStan baseline errors - #13283

Closed
nathanrice wants to merge 5 commits into
WordPress:trunkfrom
nathanrice:fix/trac-65817-method.notFound
Closed

Code Quality: Resolve method.notFound PHPStan baseline errors#13283
nathanrice wants to merge 5 commits into
WordPress:trunkfrom
nathanrice:fix/trac-65817-method.notFound

Conversation

@nathanrice

@nathanrice nathanrice commented Aug 26, 2026

Copy link
Copy Markdown

✅ Committed in r63367 (c590bda).


Summary

Resolves 5 method.notFound PHPStan baseline errors by adding property type annotations in installer/upgrader skin classes. Each skin now declares $upgrader with its specific upgrader type, allowing PHPStan to validate method calls.

Changes

  • Language_Pack_Upgrader_Skin: Annotate $upgrader as Language_Pack_Upgrader
  • Plugin_Upgrader_Skin: Annotate $upgrader as Plugin_Upgrader
  • Plugin_Installer_Skin: Annotate $upgrader as Plugin_Upgrader
  • Theme_Upgrader_Skin: Annotate $upgrader as Theme_Upgrader
  • Theme_Installer_Skin: Annotate $upgrader as Theme_Upgrader
  • Removes method.notFound.neon baseline file
  • Removes unmatched entries from property.notFound.neon baseline file

Related

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

Test Plan

  • Run composer run phpstan
  • Confirm: No errors
  • All 5 affected files pass PHPStan Level 5 validation

Use of AI Tools

AI assistance: Yes
Tool(s): Google Gemini, Claude Code
Model(s): Gemini 3.6 (Thinking), Haiku 4.5 (medium)
Used for: Understanding the problem, identifying candidates for fixing, validating changes

@github-actions

github-actions Bot commented Aug 26, 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 nathanrice, westonruter.

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

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

Comment thread src/wp-admin/includes/class-language-pack-upgrader-skin.php
pento pushed a commit that referenced this pull request Aug 27, 2026
Each `WP_Upgrader_Skin` subclass is only ever constructed with one specific upgrader, but `$upgrader` was declared only on the parent as `WP_Upgrader`. Static analysis therefore flagged the subclass-specific calls to `Plugin_Upgrader::plugin_info()`, `Theme_Upgrader::theme_info()` and `Language_Pack_Upgrader::get_name_for_update()` as calls to undefined methods. Redeclaring the property in `Language_Pack_Upgrader_Skin`, `Plugin_Upgrader_Skin`, `Plugin_Installer_Skin`, `Theme_Upgrader_Skin` and `Theme_Installer_Skin` with its narrower type documents what was already true at runtime.

The `@since` tag on each redeclaration is the version in which that skin class was introduced rather than the current release, since the property has always been available by inheritance and is not newly added here.

With those five occurrences resolved, `tests/phpstan/baselines/method.notFound.neon` is empty and is removed along with its `includes` entry in `phpstan.neon.dist`, and two entries in `property.notFound.neon` that no longer match are dropped.

Developed in #13283.
Follow-up to r63020.

Props nathanrice, westonruter.
See #65817.


git-svn-id: https://develop.svn.wordpress.org/trunk@63367 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Aug 27, 2026
Each `WP_Upgrader_Skin` subclass is only ever constructed with one specific upgrader, but `$upgrader` was declared only on the parent as `WP_Upgrader`. Static analysis therefore flagged the subclass-specific calls to `Plugin_Upgrader::plugin_info()`, `Theme_Upgrader::theme_info()` and `Language_Pack_Upgrader::get_name_for_update()` as calls to undefined methods. Redeclaring the property in `Language_Pack_Upgrader_Skin`, `Plugin_Upgrader_Skin`, `Plugin_Installer_Skin`, `Theme_Upgrader_Skin` and `Theme_Installer_Skin` with its narrower type documents what was already true at runtime.

The `@since` tag on each redeclaration is the version in which that skin class was introduced rather than the current release, since the property has always been available by inheritance and is not newly added here.

With those five occurrences resolved, `tests/phpstan/baselines/method.notFound.neon` is empty and is removed along with its `includes` entry in `phpstan.neon.dist`, and two entries in `property.notFound.neon` that no longer match are dropped.

Developed in WordPress/wordpress-develop#13283.
Follow-up to r63020.

Props nathanrice, westonruter.
See #65817.

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


git-svn-id: http://core.svn.wordpress.org/trunk@62560 1a063a9b-81f0-0310-95a4-ce76da25c4cd
jonnynews pushed a commit to spacedmonkey/wordpress-develop that referenced this pull request Sep 4, 2026
Each `WP_Upgrader_Skin` subclass is only ever constructed with one specific upgrader, but `$upgrader` was declared only on the parent as `WP_Upgrader`. Static analysis therefore flagged the subclass-specific calls to `Plugin_Upgrader::plugin_info()`, `Theme_Upgrader::theme_info()` and `Language_Pack_Upgrader::get_name_for_update()` as calls to undefined methods. Redeclaring the property in `Language_Pack_Upgrader_Skin`, `Plugin_Upgrader_Skin`, `Plugin_Installer_Skin`, `Theme_Upgrader_Skin` and `Theme_Installer_Skin` with its narrower type documents what was already true at runtime.

The `@since` tag on each redeclaration is the version in which that skin class was introduced rather than the current release, since the property has always been available by inheritance and is not newly added here.

With those five occurrences resolved, `tests/phpstan/baselines/method.notFound.neon` is empty and is removed along with its `includes` entry in `phpstan.neon.dist`, and two entries in `property.notFound.neon` that no longer match are dropped.

Developed in WordPress#13283.
Follow-up to r63020.

Props nathanrice, westonruter.
See #65817.


git-svn-id: https://develop.svn.wordpress.org/trunk@63367 602fd350-edb4-49c9-b593-d223f7449a82
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