Make WordPress Core


Ignore:
Timestamp:
04/05/2020 03:00:44 AM (6 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-includes/comment.php

    r47526 r47550  
    13861386        }
    13871387
    1388         if ( ! $force_delete && EMPTY_TRASH_DAYS && ! in_array( wp_get_comment_status( $comment ), array( 'trash', 'spam' ) ) ) {
     1388        if ( ! $force_delete && EMPTY_TRASH_DAYS && ! in_array( wp_get_comment_status( $comment ), array( 'trash', 'spam' ), true ) ) {
    13891389                return wp_trash_comment( $comment_id );
    13901390        }
     
    27532753                foreach ( (array) $to_ping as $tb_ping ) {
    27542754                        $tb_ping = trim( $tb_ping );
    2755                         if ( ! in_array( $tb_ping, $pinged ) ) {
     2755                        if ( ! in_array( $tb_ping, $pinged, true ) ) {
    27562756                                trackback( $tb_ping, $post_title, $excerpt, $post->ID );
    27572757                                $pinged[] = $tb_ping;
     
    28372837        foreach ( (array) $post_links_temp as $link_test ) {
    28382838                // If we haven't pung it already and it isn't a link to itself.
    2839                 if ( ! in_array( $link_test, $pung ) && ( url_to_postid( $link_test ) != $post->ID )
     2839                if ( ! in_array( $link_test, $pung, true ) && ( url_to_postid( $link_test ) != $post->ID )
    28402840                                // Also, let's never ping local attachments.
    28412841                                && ! is_local_attachment( $link_test ) ) {
     
    31183118         */
    31193119        $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
    3120         if ( ! in_array( $posts[0]->post_type, $post_types ) ) {
     3120        if ( ! in_array( $posts[0]->post_type, $post_types, true ) ) {
    31213121                return $posts;
    31223122        }
     
    31633163        /** This filter is documented in wp-includes/comment.php */
    31643164        $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
    3165         if ( ! in_array( $post->post_type, $post_types ) ) {
     3165        if ( ! in_array( $post->post_type, $post_types, true ) ) {
    31663166                return $open;
    31673167        }
Note: See TracChangeset for help on using the changeset viewer.