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-admin/includes/class-wp-comments-list-table.php

    r47507 r47550  
    8888
    8989                $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
    90                 if ( ! in_array( $comment_status, array( 'all', 'mine', 'moderated', 'approved', 'spam', 'trash' ) ) ) {
     90                if ( ! in_array( $comment_status, array( 'all', 'mine', 'moderated', 'approved', 'spam', 'trash' ), true ) ) {
    9191                        $comment_status = 'all';
    9292                }
     
    345345
    346346                $actions = array();
    347                 if ( in_array( $comment_status, array( 'all', 'approved' ) ) ) {
     347                if ( in_array( $comment_status, array( 'all', 'approved' ), true ) ) {
    348348                        $actions['unapprove'] = __( 'Unapprove' );
    349349                }
    350                 if ( in_array( $comment_status, array( 'all', 'moderated' ) ) ) {
     350                if ( in_array( $comment_status, array( 'all', 'moderated' ), true ) ) {
    351351                        $actions['approve'] = __( 'Approve' );
    352352                }
    353                 if ( in_array( $comment_status, array( 'all', 'moderated', 'approved', 'trash' ) ) ) {
     353                if ( in_array( $comment_status, array( 'all', 'moderated', 'approved', 'trash' ), true ) ) {
    354354                        $actions['spam'] = _x( 'Mark as Spam', 'comment' );
    355355                }
     
    361361                }
    362362
    363                 if ( in_array( $comment_status, array( 'trash', 'spam' ) ) || ! EMPTY_TRASH_DAYS ) {
     363                if ( in_array( $comment_status, array( 'trash', 'spam' ), true ) || ! EMPTY_TRASH_DAYS ) {
    364364                        $actions['delete'] = __( 'Delete Permanently' );
    365365                } else {
Note: See TracChangeset for help on using the changeset viewer.