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

    r47169 r47550  
    4343    global $wp_rewrite, $is_IIS, $wp_query, $wpdb, $wp;
    4444
    45     if ( isset( $_SERVER['REQUEST_METHOD'] ) && ! in_array( strtoupper( $_SERVER['REQUEST_METHOD'] ), array( 'GET', 'HEAD' ) ) ) {
     45    if ( isset( $_SERVER['REQUEST_METHOD'] ) && ! in_array( strtoupper( $_SERVER['REQUEST_METHOD'] ), array( 'GET', 'HEAD' ), true ) ) {
    4646        return;
    4747    }
     
    332332
    333333            $addl_path = '';
    334             if ( is_feed() && in_array( get_query_var( 'feed' ), $wp_rewrite->feeds ) ) {
     334            if ( is_feed() && in_array( get_query_var( 'feed' ), $wp_rewrite->feeds, true ) ) {
    335335                $addl_path = ! empty( $addl_path ) ? trailingslashit( $addl_path ) : '';
    336336                if ( ! is_singular() && get_query_var( 'withcomments' ) ) {
     
    752752        site_url( 'admin', 'relative' ),
    753753    );
    754     if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $admins ) ) {
     754    if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $admins, true ) ) {
    755755        wp_redirect( admin_url() );
    756756        exit;
     
    762762        site_url( 'login', 'relative' ),
    763763    );
    764     if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $logins ) ) {
     764    if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $logins, true ) ) {
    765765        wp_redirect( wp_login_url() );
    766766        exit;
Note: See TracChangeset for help on using the changeset viewer.