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/meta-boxes.php

    r47228 r47550  
    335335<span class="spinner"></span>
    336336    <?php
    337     if ( ! in_array( $post->post_status, array( 'publish', 'future', 'private' ) ) || 0 == $post->ID ) {
     337    if ( ! in_array( $post->post_status, array( 'publish', 'future', 'private' ), true ) || 0 == $post->ID ) {
    338338        if ( $can_publish ) :
    339339            if ( ! empty( $post->post_date_gmt ) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) :
     
    472472            }
    473473            // Add in the current one if it isn't there yet, in case the current theme doesn't support it.
    474             if ( $post_format && ! in_array( $post_format, $post_formats[0] ) ) {
     474            if ( $post_format && ! in_array( $post_format, $post_formats[0], true ) ) {
    475475                $post_formats[0][] = $post_format;
    476476            }
     
    848848    } else {
    849849        $hidden = get_hidden_meta_boxes( get_current_screen() );
    850         if ( ! in_array( 'commentsdiv', $hidden ) ) {
     850        if ( ! in_array( 'commentsdiv', $hidden, true ) ) {
    851851            ?>
    852852            <script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script>
     
    11831183    $rels     = preg_split( '/\s+/', $link_rel );
    11841184
    1185     if ( '' != $value && in_array( $value, $rels ) ) {
     1185    if ( '' != $value && in_array( $value, $rels, true ) ) {
    11861186        echo ' checked="checked"';
    11871187    }
     
    11971197            echo ' checked="checked"';
    11981198        }
    1199         if ( 'identity' == $class && in_array( 'me', $rels ) ) {
     1199        if ( 'identity' == $class && in_array( 'me', $rels, true ) ) {
    12001200            echo ' checked="checked"';
    12011201        }
     
    15361536    $stati[] = 'private';
    15371537
    1538     if ( in_array( get_post_status( $post ), $stati ) ) {
     1538    if ( in_array( get_post_status( $post ), $stati, true ) ) {
    15391539        // If the post type support comments, or the post has comments,
    15401540        // allow the Comments meta box.
Note: See TracChangeset for help on using the changeset viewer.