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

    r47397 r47550  
    207207
    208208        // Correct a situation where the theme is 'some-directory/some-theme' but 'some-directory' was passed in as part of the theme root instead.
    209         if ( ! in_array( $theme_root, (array) $wp_theme_directories ) && in_array( dirname( $theme_root ), (array) $wp_theme_directories ) ) {
     209        if ( ! in_array( $theme_root, (array) $wp_theme_directories, true )
     210            && in_array( dirname( $theme_root ), (array) $wp_theme_directories, true )
     211        ) {
    210212            $this->stylesheet = basename( $this->theme_root ) . '/' . $this->stylesheet;
    211213            $this->theme_root = dirname( $theme_root );
     
    476478        );
    477479
    478         return in_array( $offset, $properties );
     480        return in_array( $offset, $properties, true );
    479481    }
    480482
     
    575577        );
    576578
    577         return in_array( $offset, $keys );
     579        return in_array( $offset, $keys, true );
    578580    }
    579581
     
    662664     */
    663665    public function exists() {
    664         return ! ( $this->errors() && in_array( 'theme_not_found', $this->errors()->get_error_codes() ) );
     666        return ! ( $this->errors() && in_array( 'theme_not_found', $this->errors()->get_error_codes(), true ) );
    665667    }
    666668
     
    10301032     */
    10311033    public function get_stylesheet_directory() {
    1032         if ( $this->errors() && in_array( 'theme_root_missing', $this->errors()->get_error_codes() ) ) {
     1034        if ( $this->errors() && in_array( 'theme_root_missing', $this->errors()->get_error_codes(), true ) ) {
    10331035            return '';
    10341036        }
Note: See TracChangeset for help on using the changeset viewer.