Make WordPress Core


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

    r47267 r47550  
    4949        if ( isset( $theme_directories[ $current_theme ] ) ) {
    5050            $root_of_current_theme = get_raw_theme_root( $current_theme );
    51             if ( ! in_array( $root_of_current_theme, $wp_theme_directories ) ) {
     51            if ( ! in_array( $root_of_current_theme, $wp_theme_directories, true ) ) {
    5252                $root_of_current_theme = WP_CONTENT_DIR . $root_of_current_theme;
    5353            }
     
    120120        if ( false === $theme_root ) {
    121121            $theme_root = WP_CONTENT_DIR . '/themes';
    122         } elseif ( ! in_array( $theme_root, (array) $wp_theme_directories ) ) {
     122        } elseif ( ! in_array( $theme_root, (array) $wp_theme_directories, true ) ) {
    123123            $theme_root = WP_CONTENT_DIR . $theme_root;
    124124        }
     
    412412
    413413    $untrailed = untrailingslashit( $directory );
    414     if ( ! empty( $untrailed ) && ! in_array( $untrailed, $wp_theme_directories ) ) {
     414    if ( ! empty( $untrailed ) && ! in_array( $untrailed, $wp_theme_directories, true ) ) {
    415415        $wp_theme_directories[] = $untrailed;
    416416    }
     
    584584            // Always prepend WP_CONTENT_DIR unless the root currently registered as a theme directory.
    585585            // This gives relative theme roots the benefit of the doubt when things go haywire.
    586             if ( ! in_array( $theme_root, (array) $wp_theme_directories ) ) {
     586            if ( ! in_array( $theme_root, (array) $wp_theme_directories, true ) ) {
    587587                $theme_root = WP_CONTENT_DIR . $theme_root;
    588588            }
     
    627627
    628628    if ( $stylesheet_or_template && $theme_root ) {
    629         if ( in_array( $theme_root, (array) $wp_theme_directories ) ) {
     629        if ( in_array( $theme_root, (array) $wp_theme_directories, true ) ) {
    630630            // Absolute path. Make an educated guess. YMMV -- but note the filter below.
    631631            if ( 0 === strpos( $theme_root, WP_CONTENT_DIR ) ) {
     
    27392739function remove_theme_support( $feature ) {
    27402740    // Blacklist: for internal registrations not used directly by themes.
    2741     if ( in_array( $feature, array( 'editor-style', 'widgets', 'menus' ) ) ) {
     2741    if ( in_array( $feature, array( 'editor-style', 'widgets', 'menus' ), true ) ) {
    27422742        return false;
    27432743    }
     
    28472847             * If no array was passed, then any type is accepted.
    28482848             */
    2849             if ( true === $_wp_theme_features[ $feature ] ) {  // Registered for all types
     2849            if ( true === $_wp_theme_features[ $feature ] ) {  // Registered for all types.
    28502850                return true;
    28512851            }
    28522852            $content_type = $args[0];
    2853             return in_array( $content_type, $_wp_theme_features[ $feature ][0] );
     2853            return in_array( $content_type, $_wp_theme_features[ $feature ][0], true );
    28542854
    28552855        case 'html5':
     
    28622862             */
    28632863            $type = $args[0];
    2864             return in_array( $type, $_wp_theme_features[ $feature ][0] );
     2864            return in_array( $type, $_wp_theme_features[ $feature ][0], true );
    28652865
    28662866        case 'custom-logo':
Note: See TracChangeset for help on using the changeset viewer.