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

    r47370 r47550  
    1515function wp_get_server_protocol() {
    1616    $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : '';
    17     if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) {
     17    if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ), true ) ) {
    1818        $protocol = 'HTTP/1.0';
    1919    }
     
    4141    $input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() );
    4242    foreach ( $input as $k => $v ) {
    43         if ( ! in_array( $k, $no_unset ) && isset( $GLOBALS[ $k ] ) ) {
     43        if ( ! in_array( $k, $no_unset, true ) && isset( $GLOBALS[ $k ] ) ) {
    4444            unset( $GLOBALS[ $k ] );
    4545        }
     
    684684            && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist.
    685685            // Not already included as a network plugin.
    686             && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) )
     686            && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins, true ) )
    687687            ) {
    688688            $plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
Note: See TracChangeset for help on using the changeset viewer.