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-list-table.php

    r47219 r47550  
    182182         */
    183183        public function __get( $name ) {
    184                 if ( in_array( $name, $this->compat_fields ) ) {
     184                if ( in_array( $name, $this->compat_fields, true ) ) {
    185185                        return $this->$name;
    186186                }
     
    197197         */
    198198        public function __set( $name, $value ) {
    199                 if ( in_array( $name, $this->compat_fields ) ) {
     199                if ( in_array( $name, $this->compat_fields, true ) ) {
    200200                        return $this->$name = $value;
    201201                }
     
    211211         */
    212212        public function __isset( $name ) {
    213                 if ( in_array( $name, $this->compat_fields ) ) {
     213                if ( in_array( $name, $this->compat_fields, true ) ) {
    214214                        return isset( $this->$name );
    215215                }
     
    224224         */
    225225        public function __unset( $name ) {
    226                 if ( in_array( $name, $this->compat_fields ) ) {
     226                if ( in_array( $name, $this->compat_fields, true ) ) {
    227227                        unset( $this->$name );
    228228                }
     
    239239         */
    240240        public function __call( $name, $arguments ) {
    241                 if ( in_array( $name, $this->compat_methods ) ) {
     241                if ( in_array( $name, $this->compat_methods, true ) ) {
    242242                        return $this->$name( ...$arguments );
    243243                }
     
    11341134                        $class = array( 'manage-column', "column-$column_key" );
    11351135
    1136                         if ( in_array( $column_key, $hidden ) ) {
     1136                        if ( in_array( $column_key, $hidden, true ) ) {
    11371137                                $class[] = 'hidden';
    11381138                        }
     
    11401140                        if ( 'cb' === $column_key ) {
    11411141                                $class[] = 'check-column';
    1142                         } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) {
     1142                        } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) {
    11431143                                $class[] = 'num';
    11441144                        }
     
    13301330                        }
    13311331
    1332                         if ( in_array( $column_name, $hidden ) ) {
     1332                        if ( in_array( $column_name, $hidden, true ) ) {
    13331333                                $classes .= ' hidden';
    13341334                        }
Note: See TracChangeset for help on using the changeset viewer.