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/pomo/po.php

    r47219 r47808  
    150150                foreach ( $chars as $char ) {
    151151                    if ( ! $previous_is_backslash ) {
    152                         if ( '\\' == $char ) {
     152                        if ( '\\' === $char ) {
    153153                            $previous_is_backslash = true;
    154154                        } else {
     
    295295                    break;
    296296                }
    297                 if ( '' == $res['entry']->singular ) {
     297                if ( '' === $res['entry']->singular ) {
    298298                    $this->set_headers( $this->make_headers( $res['entry']->translations[0] ) );
    299299                } else {
     
    461461            static $last_line     = '';
    462462            static $use_last_line = false;
    463             if ( 'clear' == $action ) {
     463            if ( 'clear' === $action ) {
    464464                $last_line = '';
    465465                return true;
    466466            }
    467             if ( 'put-back' == $action ) {
     467            if ( 'put-back' === $action ) {
    468468                $use_last_line = true;
    469469                return true;
    470470            }
    471471            $line          = $use_last_line ? $last_line : fgets( $f );
    472             $line          = ( "\r\n" == substr( $line, -2 ) ) ? rtrim( $line, "\r\n" ) . "\n" : $line;
     472            $line          = ( "\r\n" === substr( $line, -2 ) ) ? rtrim( $line, "\r\n" ) . "\n" : $line;
    473473            $last_line     = $line;
    474474            $use_last_line = false;
     
    483483            $first_two = substr( $po_comment_line, 0, 2 );
    484484            $comment   = trim( substr( $po_comment_line, 2 ) );
    485             if ( '#:' == $first_two ) {
     485            if ( '#:' === $first_two ) {
    486486                $entry->references = array_merge( $entry->references, preg_split( '/\s+/', $comment ) );
    487             } elseif ( '#.' == $first_two ) {
     487            } elseif ( '#.' === $first_two ) {
    488488                $entry->extracted_comments = trim( $entry->extracted_comments . "\n" . $comment );
    489             } elseif ( '#,' == $first_two ) {
     489            } elseif ( '#,' === $first_two ) {
    490490                $entry->flags = array_merge( $entry->flags, preg_split( '/,\s*/', $comment ) );
    491491            } else {
     
    499499         */
    500500        public static function trim_quotes( $s ) {
    501             if ( substr( $s, 0, 1 ) == '"' ) {
     501            if ( '"' === substr( $s, 0, 1 ) ) {
    502502                $s = substr( $s, 1 );
    503503            }
    504             if ( substr( $s, -1, 1 ) == '"' ) {
     504            if ( '"' === substr( $s, -1, 1 ) ) {
    505505                $s = substr( $s, 0, -1 );
    506506            }
Note: See TracChangeset for help on using the changeset viewer.