Skip to content

Commit 094ed92

Browse files
committed
Build/Test Tools: Retire resolved PHPStan baselines.
Clarify pointer, metadata, and REST array types. Simplify equivalent Site Health, timezone, and upload checks while preserving the theme filter re-evaluation. Remove the resolved `empty.offset`, `booleanAnd.rightAlwaysTrue`, and `identical.alwaysTrue` baselines and the related unreachable-code entry. Developed in: #14027, #14031, #14032 Props huzaifaalmesbah. See #65817. git-svn-id: https://develop.svn.wordpress.org/trunk@65149 602fd350-edb4-49c9-b593-d223f7449a82
1 parent c82c6cb commit 094ed92

12 files changed

Lines changed: 10 additions & 112 deletions

File tree

‎phpstan.neon.dist‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,15 @@ includes:
2828
- tests/phpstan/baselines/binaryOp.invalid.neon
2929
- tests/phpstan/baselines/booleanAnd.alwaysFalse.neon
3030
- tests/phpstan/baselines/booleanAnd.leftAlwaysTrue.neon
31-
- tests/phpstan/baselines/booleanAnd.rightAlwaysTrue.neon
3231
- tests/phpstan/baselines/booleanNot.alwaysFalse.neon
3332
- tests/phpstan/baselines/booleanNot.alwaysTrue.neon
3433
- tests/phpstan/baselines/class.notFound.neon
3534
- tests/phpstan/baselines/deadCode.unreachable.neon
36-
- tests/phpstan/baselines/empty.offset.neon
3735
- tests/phpstan/baselines/empty.property.neon
3836
- tests/phpstan/baselines/empty.variable.neon
3937
- tests/phpstan/baselines/function.alreadyNarrowedType.neon
4038
- tests/phpstan/baselines/function.resultUnused.neon
4139
- tests/phpstan/baselines/identical.alwaysFalse.neon
42-
- tests/phpstan/baselines/identical.alwaysTrue.neon
4340
- tests/phpstan/baselines/if.alwaysFalse.neon
4441
- tests/phpstan/baselines/if.alwaysTrue.neon
4542
- tests/phpstan/baselines/isset.offset.neon

‎src/wp-admin/includes/class-file-upload-upgrader.php‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ public function __construct( $form, $urlholder ) {
8080
__( 'Return to the Plugin Installer' )
8181
);
8282
wp_die( __( 'Incompatible Archive.' ) . '<br />' . $plugins_page );
83-
}
84-
85-
if ( 'themezip' === $form ) {
83+
} else {
8684
$themes_page = sprintf(
8785
'<a href="%s" target="_parent">%s</a>',
8886
self_admin_url( 'theme-install.php' ),

‎src/wp-admin/includes/class-wp-internal-pointers.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public static function enqueue_scripts( $hook_suffix ) {
4848
* 'themes.php' => 'wp390_widgets'
4949
* )
5050
*/
51+
/** @var array<string, string|string[]> $registered_pointers */
5152
$registered_pointers = array(
5253
// None currently.
5354
);
@@ -72,6 +73,7 @@ public static function enqueue_scripts( $hook_suffix ) {
7273
* 'wp390_widgets' => array( 'edit_theme_options' )
7374
* )
7475
*/
76+
/** @var array<string, string[]> $caps_required */
7577
$caps_required = array(
7678
// None currently.
7779
);

‎src/wp-admin/includes/class-wp-site-health.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,6 @@ public function get_test_theme_version() {
528528

529529
$has_default_theme = false;
530530
$has_unused_themes = false;
531-
$show_unused_themes = true;
532531
$using_default_theme = false;
533532

534533
// Populate a list of all themes available in the install.
@@ -622,7 +621,7 @@ public function get_test_theme_version() {
622621
}
623622
}
624623

625-
if ( $has_unused_themes && $show_unused_themes && ! is_multisite() ) {
624+
if ( $has_unused_themes && ! is_multisite() ) {
626625

627626
// This is a child theme, so we want to be a bit more explicit in our messages.
628627
if ( $active_theme->parent() ) {

‎src/wp-admin/includes/media.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3677,6 +3677,7 @@ function wp_read_video_metadata( $file ) {
36773677
return false;
36783678
}
36793679

3680+
/** @var array<string, mixed> $metadata */
36803681
$metadata = array();
36813682

36823683
if ( ! defined( 'GETID3_TEMP_DIR' ) ) {

‎src/wp-content/themes/twentynineteen/header.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<?php
4242
twentynineteen_post_thumbnail();
4343
the_post();
44-
$discussion = ! is_page() && twentynineteen_can_show_post_thumbnail() ? twentynineteen_get_discussion_data() : null;
44+
$discussion = ! is_page() && twentynineteen_can_show_post_thumbnail() ? twentynineteen_get_discussion_data() : null; // @phpstan-ignore booleanAnd.rightAlwaysTrue (Re-checked after the_post(); the filter may return a different value.)
4545

4646
$classes = 'entry-header';
4747
if ( ! empty( $discussion ) && absint( $discussion->responses ) > 0 ) {

‎src/wp-includes/functions.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6880,9 +6880,9 @@ function wp_timezone_choice( $selected_zone, $locale = null ) {
68806880

68816881
// This determines what gets set and translated - we don't translate Etc/* strings here, they are done later.
68826882
$exists = array(
6883-
0 => ( isset( $zone[0] ) && $zone[0] ),
6884-
1 => ( isset( $zone[1] ) && $zone[1] ),
6885-
2 => ( isset( $zone[2] ) && $zone[2] ),
6883+
0 => ! empty( $zone[0] ),
6884+
1 => ! empty( $zone[1] ),
6885+
2 => ! empty( $zone[2] ),
68866886
);
68876887
$exists[3] = ( $exists[0] && 'Etc' !== $zone[0] );
68886888
$exists[4] = ( $exists[1] && $exists[3] );

‎src/wp-includes/rest-api.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,7 @@ function rest_filter_response_fields( $response, $server, $request ) {
10721072
$fields = array_map( 'trim', $fields );
10731073

10741074
// Create nested array of accepted field hierarchy.
1075+
/** @var array<string, mixed> $fields_as_keyed */
10751076
$fields_as_keyed = array();
10761077
foreach ( $fields as $field ) {
10771078
$parts = explode( '.', $field );

‎tests/phpstan/baselines/booleanAnd.rightAlwaysTrue.neon‎

Lines changed: 0 additions & 35 deletions
This file was deleted.

‎tests/phpstan/baselines/deadCode.unreachable.neon‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ parameters:
3333
identifier: deadCode.unreachable
3434
count: 3
3535
path: ../../../src/wp-admin/includes/ajax-actions.php
36-
-
37-
message: '#^Unreachable statement \- code above always terminates\.$#'
38-
identifier: deadCode.unreachable
39-
count: 1
40-
path: ../../../src/wp-admin/includes/class-wp-internal-pointers.php
4136
-
4237
message: '#^Unreachable statement \- code above always terminates\.$#'
4338
identifier: deadCode.unreachable

0 commit comments

Comments
 (0)