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

    r47122 r47550  
    9191     */
    9292    public function add_query_var( $qv ) {
    93         if ( ! in_array( $qv, $this->public_query_vars ) ) {
     93        if ( ! in_array( $qv, $this->public_query_vars, true ) ) {
    9494            $this->public_query_vars[] = $qv;
    9595        }
     
    349349            $queryable_post_types = get_post_types( array( 'publicly_queryable' => true ) );
    350350            if ( ! is_array( $this->query_vars['post_type'] ) ) {
    351                 if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types ) ) {
     351                if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types, true ) ) {
    352352                    unset( $this->query_vars['post_type'] );
    353353                }
     
    413413                }
    414414                $headers['Content-Type'] = get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' );
    415             } elseif ( in_array( $status, array( 403, 500, 502, 503 ) ) ) {
     415            } elseif ( in_array( $status, array( 403, 500, 502, 503 ), true ) ) {
    416416                $exit_required = true;
    417417            }
Note: See TracChangeset for help on using the changeset viewer.