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

    r47461 r47550  
    455455            foreach ( (array) $headers as $name => $content ) {
    456456                // Only add custom headers not added automatically by PHPMailer.
    457                 if ( ! in_array( $name, array( 'MIME-Version', 'X-Mailer' ) ) ) {
     457                if ( ! in_array( $name, array( 'MIME-Version', 'X-Mailer' ), true ) ) {
    458458                    $phpmailer->addCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
    459459                }
     
    547547        $ignore_codes = array( 'empty_username', 'empty_password' );
    548548
    549         if ( is_wp_error( $user ) && ! in_array( $user->get_error_code(), $ignore_codes ) ) {
     549        if ( is_wp_error( $user ) && ! in_array( $user->get_error_code(), $ignore_codes, true ) ) {
    550550            $error = $user;
    551551
     
    14661466        $allowed_hosts = (array) apply_filters( 'allowed_redirect_hosts', array( $wpp['host'] ), isset( $lp['host'] ) ? $lp['host'] : '' );
    14671467
    1468         if ( isset( $lp['host'] ) && ( ! in_array( $lp['host'], $allowed_hosts ) && strtolower( $wpp['host'] ) !== $lp['host'] ) ) {
     1468        if ( isset( $lp['host'] ) && ( ! in_array( $lp['host'], $allowed_hosts, true ) && strtolower( $wpp['host'] ) !== $lp['host'] ) ) {
    14691469            $location = $default;
    14701470        }
     
    22722272        }
    22732273
    2274         if ( in_array( $scheme, array( 'auth', 'secure_auth', 'logged_in', 'nonce' ) ) ) {
     2274        if ( in_array( $scheme, array( 'auth', 'secure_auth', 'logged_in', 'nonce' ), true ) ) {
    22752275            foreach ( array( 'key', 'salt' ) as $type ) {
    22762276                $const = strtoupper( "{$scheme}_{$type}" );
Note: See TracChangeset for help on using the changeset viewer.