Make WordPress Core

Changeset 63367


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.

Location:
trunk
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpstan.neon.dist

    r63357 r63367  
    5858        - tests/phpstan/baselines/method.childParameterType.neon
    5959        - tests/phpstan/baselines/method.nonObject.neon
    60         - tests/phpstan/baselines/method.notFound.neon
    6160        - tests/phpstan/baselines/method.unused.neon
    6261        - tests/phpstan/baselines/notIdentical.alwaysTrue.neon
  • trunk/src/wp-admin/includes/class-language-pack-upgrader-skin.php

    r58082 r63367  
    1717 */
    1818class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
     19        /**
     20         * The upgrader instance.
     21         *
     22         * @since 3.7.0
     23         * @var Language_Pack_Upgrader
     24         */
     25        public $upgrader;
     26
    1927        public $language_update        = null;
    2028        public $done_header            = false;
  • 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;
  • trunk/src/wp-admin/includes/class-plugin-upgrader-skin.php

    r55911 r63367  
    1717 */
    1818class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
     19        /**
     20         * The upgrader instance.
     21         *
     22         * @since 2.8.0
     23         * @var Plugin_Upgrader
     24         */
     25        public $upgrader;
    1926
    2027        /**
  • trunk/src/wp-admin/includes/class-theme-installer-skin.php

    r63177 r63367  
    1717 */
    1818class Theme_Installer_Skin extends WP_Upgrader_Skin {
     19        /**
     20         * The upgrader instance.
     21         *
     22         * @since 2.8.0
     23         * @var Theme_Upgrader
     24         */
     25        public $upgrader;
     26
    1927        public $api;
    2028        public $type;
  • trunk/src/wp-admin/includes/class-theme-upgrader-skin.php

    r57714 r63367  
    1717 */
    1818class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
     19
     20        /**
     21         * The upgrader instance.
     22         *
     23         * @since 2.8.0
     24         * @var Theme_Upgrader
     25         */
     26        public $upgrader;
    1927
    2028        /**
  • trunk/tests/phpstan/baselines/property.notFound.neon

    r63020 r63367  
    2525                        path: ../../../src/wp-admin/includes/class-language-pack-upgrader.php
    2626                -
    27                         message: '#^Access to an undefined property WP_Upgrader\:\:\$new_plugin_data\.$#'
    28                         identifier: property.notFound
    29                         count: 1
    30                         path: ../../../src/wp-admin/includes/class-plugin-installer-skin.php
    31                 -
    3227                        message: '#^Access to an undefined property WP_Upgrader_Skin\:\:\$plugin_active\.$#'
    3328                        identifier: property.notFound
     
    3934                        count: 1
    4035                        path: ../../../src/wp-admin/includes/class-plugin-upgrader.php
    41                 -
    42                         message: '#^Access to an undefined property WP_Upgrader\:\:\$new_theme_data\.$#'
    43                         identifier: property.notFound
    44                         count: 1
    45                         path: ../../../src/wp-admin/includes/class-theme-installer-skin.php
    4636                -
    4737                        message: '#^Access to an undefined property WP_Upgrader_Skin\:\:\$api\.$#'
Note: See TracChangeset for help on using the changeset viewer.