Make WordPress Core


Ignore:
Timestamp:
05/16/2020 06:40:52 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison where static strings are involved.

This reduces the number of WordPress.PHP.StrictComparisons.LooseComparison issues in half, from 1897 to 890.

Includes minor code layout fixes for better readability.

See #49542.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r47617 r47808  
    330330            // Get the site domain and get rid of www.
    331331            $sitename = strtolower( $_SERVER['SERVER_NAME'] );
    332             if ( substr( $sitename, 0, 4 ) == 'www.' ) {
     332            if ( 'www.' === substr( $sitename, 0, 4 ) ) {
    333333                $sitename = substr( $sitename, 4 );
    334334            }
     
    433433
    434434        // Set whether it's plaintext, depending on $content_type.
    435         if ( 'text/html' == $content_type ) {
     435        if ( 'text/html' === $content_type ) {
    436436            $phpmailer->isHTML( true );
    437437        }
     
    634634
    635635        // Allow a grace period for POST and Ajax requests.
    636         if ( wp_doing_ajax() || 'POST' == $_SERVER['REQUEST_METHOD'] ) {
     636        if ( wp_doing_ajax() || 'POST' === $_SERVER['REQUEST_METHOD'] ) {
    637637            $expired += HOUR_IN_SECONDS;
    638638        }
     
    12671267        $location = wp_sanitize_redirect( $location );
    12681268
    1269         if ( ! $is_IIS && PHP_SAPI != 'cgi-fcgi' ) {
     1269        if ( ! $is_IIS && 'cgi-fcgi' !== PHP_SAPI ) {
    12701270            status_header( $status ); // This causes problems on IIS and some FastCGI setups.
    12711271        }
     
    14151415        $location = trim( $location, " \t\n\r\0\x08\x0B" );
    14161416        // Browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'.
    1417         if ( substr( $location, 0, 2 ) == '//' ) {
     1417        if ( '//' === substr( $location, 0, 2 ) ) {
    14181418            $location = 'http:' . $location;
    14191419        }
     
    14321432
    14331433        // Allow only 'http' and 'https' schemes. No 'data:', etc.
    1434         if ( isset( $lp['scheme'] ) && ! ( 'http' == $lp['scheme'] || 'https' == $lp['scheme'] ) ) {
     1434        if ( isset( $lp['scheme'] ) && ! ( 'http' === $lp['scheme'] || 'https' === $lp['scheme'] ) ) {
    14351435            return $default;
    14361436        }
     
    16471647        $wp_email = 'wordpress@' . preg_replace( '#^www\.#', '', strtolower( $_SERVER['SERVER_NAME'] ) );
    16481648
    1649         if ( '' == $comment->comment_author ) {
     1649        if ( '' === $comment->comment_author ) {
    16501650            $from = "From: \"$blogname\" <$wp_email>";
    1651             if ( '' != $comment->comment_author_email ) {
     1651            if ( '' !== $comment->comment_author_email ) {
    16521652                $reply_to = "Reply-To: $comment->comment_author_email";
    16531653            }
    16541654        } else {
    16551655            $from = "From: \"$comment->comment_author\" <$wp_email>";
    1656             if ( '' != $comment->comment_author_email ) {
     1656            if ( '' !== $comment->comment_author_email ) {
    16571657                $reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>";
    16581658            }
     
    22722272            $values['key'] = SECRET_KEY;
    22732273        }
    2274         if ( 'auth' == $scheme && defined( 'SECRET_SALT' ) && SECRET_SALT && empty( $duplicated_keys[ SECRET_SALT ] ) ) {
     2274        if ( 'auth' === $scheme && defined( 'SECRET_SALT' ) && SECRET_SALT && empty( $duplicated_keys[ SECRET_SALT ] ) ) {
    22752275            $values['salt'] = SECRET_SALT;
    22762276        }
Note: See TracChangeset for help on using the changeset viewer.