Changeset 64435
- Timestamp:
- 10/16/2026 11:46:27 PM (25 hours ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
src/wp-admin/includes/class-language-pack-upgrader.php (modified) (2 diffs)
-
src/wp-admin/includes/class-plugin-upgrader.php (modified) (3 diffs)
-
src/wp-admin/includes/class-theme-upgrader.php (modified) (4 diffs)
-
src/wp-admin/includes/class-wp-automatic-updater.php (modified) (15 diffs)
-
src/wp-admin/includes/class-wp-upgrader.php (modified) (1 diff)
-
tests/phpstan/baselines/argument.type.neon (modified) (2 diffs)
-
tests/phpstan/baselines/return.type.neon (modified) (1 diff)
-
tests/phpstan/baselines/variable.undefined.neon (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-language-pack-upgrader.php
r61455 r64435 23 23 * 24 24 * @since 3.7.0 25 * @var array|WP_Error $result 25 * @var array|WP_Error|null $result 26 * @phpstan-var non-empty-array<string, mixed>|WP_Error|null 26 27 * @see WP_Upgrader::$result 27 28 */ … … 128 129 * @since 3.7.0 129 130 * 130 * @param string|false $update Optional. Whether an update offer is available. Default false. 131 * @param object|false $update Optional. The language pack update offer, or false to upgrade all 132 * available language packs. Default false. 131 133 * @param array $args Optional. Other optional arguments, see 132 134 * Language_Pack_Upgrader::bulk_upgrade(). Default empty array. 133 * @return array|bool|WP_Error The result of the upgrade, or a WP_Error object instead. 135 * @return array|bool|WP_Error|null The result of the upgrade, or a WP_Error object instead. Null if the 136 * upgrade failed before the package was installed, for example when 137 * the package could not be downloaded. 134 138 */ 135 139 public function upgrade( $update = false, $args = array() ) { -
trunk/src/wp-admin/includes/class-plugin-upgrader.php
r63788 r64435 25 25 * 26 26 * @since 2.8.0 27 * @var array|WP_Error $result 27 * @var array|WP_Error|null $result 28 * @phpstan-var non-empty-array<string, mixed>|WP_Error|null 28 29 * 29 30 * @see WP_Upgrader::$result … … 114 115 * Default true. 115 116 * } 116 * @return bool|WP_Error True if the installation was successful, false or a WP_Error otherwise. 117 * @return bool|WP_Error|null True if the installation was successful, false or a WP_Error otherwise. 118 * Null if the installation failed before the package was installed, for 119 * example when the package could not be downloaded. 117 120 */ 118 121 public function install( $package, $args = array() ) { … … 186 189 * Default true. 187 190 * } 188 * @return bool|WP_Error True if the upgrade was successful, false or a WP_Error object otherwise. 191 * @return bool|WP_Error|null True if the upgrade was successful, false or a WP_Error object otherwise. 192 * Null if the upgrade failed before the package was installed, for example 193 * when the package could not be downloaded. 189 194 */ 190 195 public function upgrade( $plugin, $args = array() ) { -
trunk/src/wp-admin/includes/class-theme-upgrader.php
r63788 r64435 25 25 * 26 26 * @since 2.8.0 27 * @var array|WP_Error $result 27 * @var array|WP_Error|null $result 28 * @phpstan-var non-empty-array<string, mixed>|WP_Error|null 28 29 * @see WP_Upgrader::$result 29 30 */ … … 121 122 * @param array $child_result 122 123 * @return bool 124 * 125 * @phpstan-param non-empty-array<string, mixed> $child_result 123 126 */ 124 127 public function check_parent_theme_filter( $install_result, $hook_extra, $child_result ) { … … 226 229 * } 227 230 * 228 * @return bool|WP_Error True if the installation was successful, false or a WP_Error object otherwise. 231 * @return bool|WP_Error|null True if the installation was successful, false or a WP_Error object otherwise. 232 * Null if the installation failed before the package was installed, for 233 * example when the package could not be downloaded. 229 234 */ 230 235 public function install( $package, $args = array() ) { … … 291 296 * Default true. 292 297 * } 293 * @return bool|WP_Error True if the upgrade was successful, false or a WP_Error object otherwise. 298 * @return bool|WP_Error|null True if the upgrade was successful, false or a WP_Error object otherwise. 299 * Null if the upgrade failed before the package was installed, for example 300 * when the package could not be downloaded. 294 301 */ 295 302 public function upgrade( $theme, $args = array() ) { -
trunk/src/wp-admin/includes/class-wp-automatic-updater.php
r63494 r64435 13 13 * @since 3.7.0 14 14 * @since 4.6.0 Moved to its own file from wp-admin/includes/class-wp-upgrader.php. 15 * 16 * @phpstan-type Core_Update_Offer object{ 17 * current: string, 18 * version: string, 19 * php_version: string, 20 * mysql_version: string, 21 * new_files?: bool|string, 22 * notify_email?: bool|string, 23 * autoupdate?: bool, 24 * disable_autoupdate?: bool, 25 * }&stdClass 26 * @phpstan-type Plugin_Update_Offer object{ 27 * slug: string, 28 * plugin: string, 29 * new_version: string, 30 * current_version?: string|false, 31 * requires_php?: string|false|null, 32 * autoupdate?: bool, 33 * disable_autoupdate?: bool, 34 * }&stdClass 35 * @phpstan-type Theme_Update_Offer object{ 36 * theme: string, 37 * new_version: string, 38 * current_version?: string|false, 39 * requires_php?: string|false|null, 40 * autoupdate?: bool, 41 * disable_autoupdate?: bool, 42 * }&stdClass 43 * @phpstan-type Translation_Update_Offer object{ 44 * language: string, 45 * autoupdate?: bool, 46 * disable_autoupdate?: bool, 47 * }&stdClass 48 * @phpstan-type Core_Update_Result object{ 49 * item: Core_Update_Offer, 50 * result: string|WP_Error, 51 * name: string, 52 * messages: string[], 53 * }&stdClass 54 * @phpstan-type Plugin_Update_Result object{ 55 * item: Plugin_Update_Offer, 56 * result: true|WP_Error|null, 57 * name: string, 58 * messages: string[], 59 * }&stdClass 60 * @phpstan-type Theme_Update_Result object{ 61 * item: Theme_Update_Offer, 62 * result: true|WP_Error|null, 63 * name: string|false, 64 * messages: string[], 65 * }&stdClass 66 * @phpstan-type Translation_Update_Result object{ 67 * item: Translation_Update_Offer, 68 * result: array<mixed>|true|WP_Error|null, 69 * name: string, 70 * messages: string[], 71 * }&stdClass 15 72 */ 16 73 #[AllowDynamicProperties] … … 20 77 * Tracks update results during processing. 21 78 * 22 * @var array 79 * @var array<string, object[]> 80 * @phpstan-var array{ 81 * core?: list<Core_Update_Result>, 82 * plugin?: list<Plugin_Update_Result>, 83 * theme?: list<Theme_Update_Result>, 84 * translation?: list<Translation_Update_Result>, 85 * } 23 86 */ 24 87 protected $update_results = array(); … … 192 255 * access and status should be checked. 193 256 * @return bool True if the item should be updated, false otherwise. 257 * 258 * @phpstan-param 'core'|'theme'|'plugin'|'translation' $type 259 * @phpstan-param (Core_Update_Offer|Plugin_Update_Offer|Theme_Update_Offer|Translation_Update_Offer) $item 194 260 */ 195 261 public function should_update( $type, $item, $context ) { … … 217 283 } 218 284 219 // Next up, is this an item we can update? 285 /* 286 * Next up, is this an item we can update? 287 * 288 * The inline @phpstan-var tags narrow $item by $type. This should be replaced with a conditional 289 * parameter type once PHPStan supports narrowing nested conditional parameter types. 290 */ 220 291 if ( 'core' === $type ) { 292 /** @phpstan-var Core_Update_Offer $item */ 221 293 $update = Core_Upgrader::should_update_to_version( $item->current ); 222 294 } elseif ( 'plugin' === $type || 'theme' === $type ) { 295 /** @phpstan-var (Plugin_Update_Offer|Theme_Update_Offer) $item */ 223 296 $update = ! empty( $item->autoupdate ); 224 297 … … 279 352 global $wpdb; 280 353 354 /** @phpstan-var Core_Update_Offer $item */ 281 355 $php_compat = version_compare( PHP_VERSION, $item->php_version, '>=' ); 282 356 if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) { … … 293 367 // If updating a plugin or theme, ensure the minimum PHP version requirements are satisfied. 294 368 if ( in_array( $type, array( 'plugin', 'theme' ), true ) ) { 369 /** @phpstan-var (Plugin_Update_Offer|Theme_Update_Offer) $item */ 295 370 if ( ! empty( $item->requires_php ) && version_compare( PHP_VERSION, $item->requires_php, '<' ) ) { 296 371 return false; … … 358 433 * @param string $type The type of update being checked: 'core', 'theme', 'plugin', 'translation'. 359 434 * @param object $item The update offer. 360 * @return null|WP_Error 435 * @return WP_Error|bool|string|array|null False if the item should not be updated, otherwise the result 436 * from the upgrader: the new WordPress version for core, true for 437 * a successful plugin or theme update, the installation result for 438 * a translation, or a WP_Error on failure. Null for a plugin, theme, 439 * or translation if the update failed before the package was 440 * installed. 441 * 442 * @phpstan-param 'core'|'theme'|'plugin'|'translation' $type 443 * @phpstan-param (Core_Update_Offer|Plugin_Update_Offer|Theme_Update_Offer|Translation_Update_Offer) $item 444 * @phpstan-return ( 445 * $type is 'core' ? string|false|WP_Error : ( 446 * $type is 'translation' ? array<mixed>|bool|WP_Error|null : bool|WP_Error|null 447 * ) 448 * ) 361 449 */ 362 450 public function update( $type, $item ) { 363 451 $skin = new Automatic_Upgrader_Skin(); 364 452 453 /* 454 * The inline @phpstan-var tags narrow $item by $type. This should be replaced with a conditional 455 * parameter type once PHPStan supports narrowing nested conditional parameter types. 456 */ 457 $upgrader = null; 458 $context = null; 365 459 switch ( $type ) { 366 460 case 'core': 461 /** @phpstan-var Core_Update_Offer $item */ 367 462 // The Core upgrader doesn't use the Upgrader's skin during the actual main part of the upgrade, instead, firing a filter. 368 463 add_filter( 'update_feedback', array( $skin, 'feedback' ) ); … … 371 466 break; 372 467 case 'plugin': 468 /** @phpstan-var Plugin_Update_Offer $item */ 373 469 $upgrader = new Plugin_Upgrader( $skin ); 374 470 $context = WP_PLUGIN_DIR; // We don't support custom Plugin directories, or updates for WPMU_PLUGIN_DIR. 375 471 break; 376 472 case 'theme': 473 /** @phpstan-var Theme_Update_Offer $item */ 377 474 $upgrader = new Theme_Upgrader( $skin ); 378 475 $context = get_theme_root( $item->theme ); 379 476 break; 380 477 case 'translation': 478 /** @phpstan-var Translation_Update_Offer $item */ 381 479 $upgrader = new Language_Pack_Upgrader( $skin ); 382 480 $context = WP_CONTENT_DIR; // WP_LANG_DIR; … … 401 499 do_action( 'pre_auto_update', $type, $item, $context ); 402 500 501 $item_name = null; 403 502 $upgrader_item = $item; 404 503 switch ( $type ) { 405 504 case 'core': 505 /** @phpstan-var Core_Update_Offer $item */ 406 506 /* translators: %s: WordPress version. */ 407 507 $skin->feedback( __( 'Updating to WordPress %s' ), $item->version ); … … 410 510 break; 411 511 case 'theme': 512 /** @phpstan-var Theme_Update_Offer $item */ 412 513 $upgrader_item = $item->theme; 413 514 $theme = wp_get_theme( $upgrader_item ); … … 422 523 break; 423 524 case 'plugin': 525 /** @phpstan-var Plugin_Update_Offer $item */ 424 526 $upgrader_item = $item->plugin; 425 527 $plugin_data = get_plugin_data( $context . '/' . $upgrader_item ); … … 434 536 break; 435 537 case 'translation': 538 /** @phpstan-var Translation_Update_Offer $item */ 539 /** @var Language_Pack_Upgrader $upgrader */ 436 540 $language_item_name = $upgrader->get_name_for_update( $item ); 437 541 /* translators: %s: Project name (plugin, theme, or WordPress). */ … … 447 551 } 448 552 449 $is_debug = WP_DEBUG && WP_DEBUG_LOG; 553 $was_active = null; 554 $is_debug = WP_DEBUG && WP_DEBUG_LOG; 450 555 if ( 'plugin' === $type ) { 556 /** @phpstan-var Plugin_Update_Offer $item */ 557 /** @var string $upgrader_item */ 451 558 $was_active = is_plugin_active( $upgrader_item ); 452 559 if ( $is_debug ) { … … 456 563 457 564 if ( 'theme' === $type && $is_debug ) { 565 /** @phpstan-var Theme_Update_Offer $item */ 458 566 error_log( ' Upgrading theme ' . var_export( $item->theme, true ) . '...' ); 459 567 } … … 531 639 } 532 640 533 $is_debug = WP_DEBUG && WP_DEBUG_LOG;534 535 641 if ( 'theme' === $type && $is_debug ) { 642 /** @phpstan-var Theme_Update_Offer $item */ 536 643 error_log( ' Theme ' . var_export( $item->theme, true ) . ' has been upgraded.' ); 537 644 } 538 645 539 646 if ( 'plugin' === $type ) { 647 /** @phpstan-var Plugin_Update_Offer $item */ 648 /** @var string $upgrader_item */ 540 649 if ( $is_debug ) { 541 650 error_log( ' Plugin ' . var_export( $item->slug, true ) . ' has been upgraded.' ); -
trunk/src/wp-admin/includes/class-wp-upgrader.php
r62532 r64435 74 74 * successfully. It will then be an array, unless a WP_Error is returned by the 75 75 * {@see 'upgrader_post_install'} filter. In that case, the WP_Error will be assigned to 76 * it. 76 * it. Until then, it is an empty array, or null in subclasses which redeclare it. 77 77 * 78 78 * @since 2.8.0 79 79 * 80 * @var array|WP_Error $result {80 * @var array|WP_Error|null $result { 81 81 * @type string $source The full path to the source the files were installed from. 82 82 * @type string $source_files List of all the files in the source directory. -
trunk/tests/phpstan/baselines/argument.type.neon
r64311 r64435 100 100 path: ../../../src/wp-admin/includes/class-custom-image-header.php 101 101 - 102 message: '#^Parameter \#1 \$language_updates of method Language_Pack_Upgrader\:\:bulk_upgrade\(\) expects array\<object\>, list\<string\>\|string\|false given\.$#'103 identifier: argument.type104 count: 1105 path: ../../../src/wp-admin/includes/class-language-pack-upgrader.php106 -107 102 message: '#^Parameter \#1 \$str of function md5 expects string, int given\.$#' 108 103 identifier: argument.type … … 305 300 path: ../../../src/wp-admin/includes/template.php 306 301 - 307 message: '#^Parameter \#1 \$update of method Language_Pack_Upgrader\:\:upgrade\(\) expects string\|false, object\{language\: string, version\: string, updated\: string, english_name\: string, native_name\: string, package\: string, iso\: array\<string\>, strings\: array\}&stdClass given\.$#'308 identifier: argument.type309 count: 1310 path: ../../../src/wp-admin/includes/translation-install.php311 -312 302 message: '#^Parameter \#3 \$overwrite of method WP_Filesystem_Base\:\:copy\(\) expects bool, int given\.$#' 313 303 identifier: argument.type -
trunk/tests/phpstan/baselines/return.type.neon
r63789 r64435 19 19 parameters: 20 20 ignoreErrors: 21 -22 message: '#^Method WP_Automatic_Updater\:\:update\(\) should return WP_Error\|null but returns false\.$#'23 identifier: return.type24 count: 225 path: ../../../src/wp-admin/includes/class-wp-automatic-updater.php26 21 - 27 22 message: '#^Function convert_to_screen\(\) should return WP_Screen but returns object\{id\: string, base\: string\}&stdClass\.$#' -
trunk/tests/phpstan/baselines/variable.undefined.neon
r64402 r64435 160 160 path: ../../../src/wp-admin/includes/class-core-upgrader.php 161 161 - 162 message: '#^Variable \$context might not be defined\.$#'163 identifier: variable.undefined164 count: 3165 path: ../../../src/wp-admin/includes/class-wp-automatic-updater.php166 -167 message: '#^Variable \$item_name might not be defined\.$#'168 identifier: variable.undefined169 count: 1170 path: ../../../src/wp-admin/includes/class-wp-automatic-updater.php171 -172 162 message: '#^Variable \$subject might not be defined\.$#' 173 identifier: variable.undefined174 count: 1175 path: ../../../src/wp-admin/includes/class-wp-automatic-updater.php176 -177 message: '#^Variable \$upgrader might not be defined\.$#'178 identifier: variable.undefined179 count: 8180 path: ../../../src/wp-admin/includes/class-wp-automatic-updater.php181 -182 message: '#^Variable \$was_active might not be defined\.$#'183 163 identifier: variable.undefined 184 164 count: 1
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)