Make WordPress Core


Ignore:
Timestamp:
08/27/2026 07:45:27 PM (8 days ago)
Author:
westonruter
Message:

Code Quality: Narrow $upgrader type in upgrader skins.

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 https://github.com/WordPress/wordpress-develop/pull/13283.
Follow-up to r63020.

Props nathanrice, westonruter.
See #65817.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-plugin-installer-skin.php

    r61455 r63367  
    1717 */
    1818class Plugin_Installer_Skin extends WP_Upgrader_Skin {
     19        /**
     20         * The upgrader instance.
     21         *
     22         * @since 2.8.0
     23         * @var Plugin_Upgrader
     24         */
     25        public $upgrader;
     26
    1927        public $api;
    2028        public $type;
Note: See TracChangeset for help on using the changeset viewer.