Make WordPress Core


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

    r47373 r47550  
    133133    }
    134134
    135     if ( in_array( $option, array( 'siteurl', 'home', 'category_base', 'tag_base' ) ) ) {
     135    if ( in_array( $option, array( 'siteurl', 'home', 'category_base', 'tag_base' ), true ) ) {
    136136        $value = untrailingslashit( $value );
    137137    }
     
    17731773        $no_timeout       = array( 'update_core', 'update_plugins', 'update_themes' );
    17741774        $transient_option = '_site_transient_' . $transient;
    1775         if ( ! in_array( $transient, $no_timeout ) ) {
     1775        if ( ! in_array( $transient, $no_timeout, true ) ) {
    17761776            $transient_timeout = '_site_transient_timeout_' . $transient;
    17771777            $timeout           = get_site_option( $transient_timeout );
     
    22332233    }
    22342234
    2235     $pos = array_search( $option_name, (array) $new_whitelist_options[ $option_group ] );
     2235    $pos = array_search( $option_name, (array) $new_whitelist_options[ $option_group ], true );
    22362236    if ( false !== $pos ) {
    22372237        unset( $new_whitelist_options[ $option_group ][ $pos ] );
Note: See TracChangeset for help on using the changeset viewer.