Code Quality: Resolve method.notFound PHPStan baseline errors - #13283
Code Quality: Resolve method.notFound PHPStan baseline errors#13283nathanrice wants to merge 5 commits into
Conversation
…n classes for PHPStan compliance.
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
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
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
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
✅ Committed in r63367 (c590bda).
Summary
Resolves 5
method.notFoundPHPStan baseline errors by adding property type annotations in installer/upgrader skin classes. Each skin now declares$upgraderwith its specific upgrader type, allowing PHPStan to validate method calls.Changes
Language_Pack_Upgrader_Skin: Annotate$upgraderasLanguage_Pack_UpgraderPlugin_Upgrader_Skin: Annotate$upgraderasPlugin_UpgraderPlugin_Installer_Skin: Annotate$upgraderasPlugin_UpgraderTheme_Upgrader_Skin: Annotate$upgraderasTheme_UpgraderTheme_Installer_Skin: Annotate$upgraderasTheme_Upgradermethod.notFound.neonbaseline fileproperty.notFound.neonbaseline fileRelated
Trac ticket: https://core.trac.wordpress.org/ticket/65817
Test Plan
composer run phpstanUse 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