Make WordPress Core


Ignore:
Timestamp:
04/05/2020 03:00:44 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict type check for in_array() and array_search() where strings are involved.

This reduces the number of WordPress.PHP.StrictInArray.MissingTrueStrict issues from 486 to 50.

Includes minor code layout fixes for better readability.

See #49542.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/template.php

    r47233 r47550  
    784784
    785785    if ( $for_post ) {
    786         $edit = ! ( in_array( $post->post_status, array( 'draft', 'pending' ) ) && ( ! $post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) );
     786        $edit = ! ( in_array( $post->post_status, array( 'draft', 'pending' ), true ) && ( ! $post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) );
    787787    }
    788788
     
    12981298                    $i++;
    12991299                    // get_hidden_meta_boxes() doesn't apply in the block editor.
    1300                     $hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden ) ) ? ' hide-if-js' : '';
     1300                    $hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden, true ) ) ? ' hide-if-js' : '';
    13011301                    echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes( $box['id'], $page ) . $hidden_class . '" ' . '>' . "\n";
    13021302                    if ( 'dashboard_browser_nag' != $box['id'] ) {
     
    14541454                    }
    14551455                    $i++;
    1456                     $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
     1456                    $hidden_class = in_array( $box['id'], $hidden, true ) ? 'hide-if-js' : '';
    14571457
    14581458                    $open_class = '';
     
    18391839        }
    18401840
    1841         if ( in_array( $details['type'], array( 'error', 'success', 'warning', 'info' ) ) ) {
     1841        if ( in_array( $details['type'], array( 'error', 'success', 'warning', 'info' ), true ) ) {
    18421842            $details['type'] = 'notice-' . $details['type'];
    18431843        }
     
    23742374            continue;
    23752375        }
    2376         $classes[] = in_array( $t, $button_shorthand ) ? 'button-' . $t : $t;
     2376        $classes[] = in_array( $t, $button_shorthand, true ) ? 'button-' . $t : $t;
    23772377    }
    23782378    // Remove empty items, remove duplicate items, and finally build a string.
Note: See TracChangeset for help on using the changeset viewer.