Make WordPress Core


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

    r47280 r47550  
    401401        if ( is_numeric( $offset_or_tz ) ) {
    402402                $gmt_offset = $offset_or_tz;
    403         } elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list() ) ) {
     403        } elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list(), true ) ) {
    404404                        $timezone_string = $offset_or_tz;
    405405        }
    … …  
    564564
    565565        $insert = '';
     566
    566567        foreach ( $options as $option => $value ) {
    567                 if ( in_array( $option, $existing_options ) ) {
     568                if ( in_array( $option, $existing_options, true ) ) {
    568569                        continue;
    569570                }
    570                 if ( in_array( $option, $fat_options ) ) {
     571
     572                if ( in_array( $option, $fat_options, true ) ) {
    571573                        $autoload = 'no';
    572574                } else {
    … …  
    577579                        $value = serialize( $value );
    578580                }
     581
    579582                if ( ! empty( $insert ) ) {
    580583                        $insert .= ', ';
    581584                }
     585
    582586                $insert .= $wpdb->prepare( '(%s, %s, %s)', $option, $value, $autoload );
    583587        }
Note: See TracChangeset for help on using the changeset viewer.