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/rewrite.php

    r47468 r47550  
    248248    global $wp_rewrite;
    249249
    250     if ( ! in_array( $feedname, $wp_rewrite->feeds ) ) {
     250    if ( ! in_array( $feedname, $wp_rewrite->feeds, true ) ) {
    251251        $wp_rewrite->feeds[] = $feedname;
    252252    }
     
    365365    // Identify the 'postname' position in the permastruct array.
    366366    $permastructs   = array_values( array_filter( explode( '/', get_option( 'permalink_structure' ) ) ) );
    367     $postname_index = array_search( '%postname%', $permastructs );
     367    $postname_index = array_search( '%postname%', $permastructs, true );
    368368
    369369    if ( false === $postname_index ) {
     
    597597            $query = array();
    598598            foreach ( (array) $query_vars as $key => $value ) {
    599                 if ( in_array( $key, $wp->public_query_vars ) ) {
     599                if ( in_array( $key, $wp->public_query_vars, true ) ) {
    600600                    $query[ $key ] = $value;
    601601                    if ( isset( $post_type_query_vars[ $key ] ) ) {
Note: See TracChangeset for help on using the changeset viewer.