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/wp-db.php

    r47451 r47550  
    866866
    867867                foreach ( $modes as $i => $mode ) {
    868                         if ( in_array( $mode, $incompatible_modes ) ) {
     868                        if ( in_array( $mode, $incompatible_modes, true ) ) {
    869869                                unset( $modes[ $i ] );
    870870                        }
     
    10401040                        $global_tables = array_merge( $this->global_tables, $this->ms_global_tables );
    10411041                        foreach ( $tables as $k => $table ) {
    1042                                 if ( in_array( $table, $global_tables ) ) {
     1042                                if ( in_array( $table, $global_tables, true ) ) {
    10431043                                        $tables[ $table ] = $base_prefix . $table;
    10441044                                } else {
     
    22102210                $this->insert_id = 0;
    22112211
    2212                 if ( ! in_array( strtoupper( $type ), array( 'REPLACE', 'INSERT' ) ) ) {
     2212                if ( ! in_array( strtoupper( $type ), array( 'REPLACE', 'INSERT' ), true ) ) {
    22132213                        return false;
    22142214                }
     
    27442744
    27452745                        // A binary/blob means the whole query gets treated like this.
    2746                         if ( in_array( strtoupper( $type ), array( 'BINARY', 'VARBINARY', 'TINYBLOB', 'MEDIUMBLOB', 'BLOB', 'LONGBLOB' ) ) ) {
     2746                        if ( in_array( strtoupper( $type ), array( 'BINARY', 'VARBINARY', 'TINYBLOB', 'MEDIUMBLOB', 'BLOB', 'LONGBLOB' ), true ) ) {
    27472747                                $this->table_charset[ $tablekey ] = 'binary';
    27482748                                return 'binary';
Note: See TracChangeset for help on using the changeset viewer.