Make WordPress Core


Ignore:
Timestamp:
02/09/2020 04:52:28 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use Yoda conditions where appropriate.

See #49222.

File:
1 edited

Legend:

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

    r47122 r47219  
    480480
    481481            // Malformed HTML?
    482             if ( $start === false ) {
     482            if ( false === $start ) {
    483483                $pee .= $pee_part;
    484484                continue;
     
    985985    $_quote_style = $quote_style;
    986986
    987     if ( $quote_style === 'double' ) {
     987    if ( 'double' === $quote_style ) {
    988988        $quote_style  = ENT_COMPAT;
    989989        $_quote_style = ENT_COMPAT;
    990     } elseif ( $quote_style === 'single' ) {
     990    } elseif ( 'single' === $quote_style ) {
    991991        $quote_style = ENT_NOQUOTES;
    992992    }
     
    10811081    );
    10821082
    1083     if ( $quote_style === ENT_QUOTES ) {
     1083    if ( ENT_QUOTES === $quote_style ) {
    10841084        $translation      = array_merge( $single, $double, $others );
    10851085        $translation_preg = array_merge( $single_preg, $double_preg, $others_preg );
    1086     } elseif ( $quote_style === ENT_COMPAT || $quote_style === 'double' ) {
     1086    } elseif ( ENT_COMPAT === $quote_style || 'double' === $quote_style ) {
    10871087        $translation      = array_merge( $double, $others );
    10881088        $translation_preg = array_merge( $double_preg, $others_preg );
    1089     } elseif ( $quote_style === 'single' ) {
     1089    } elseif ( 'single' === $quote_style ) {
    10901090        $translation      = array_merge( $single, $others );
    10911091        $translation_preg = array_merge( $single_preg, $others_preg );
    1092     } elseif ( $quote_style === ENT_NOQUOTES ) {
     1092    } elseif ( ENT_NOQUOTES === $quote_style ) {
    10931093        $translation      = $others;
    10941094        $translation_preg = $others_preg;
     
    27942794    for ( $i = 0, $len = strlen( $email_address ); $i < $len; $i++ ) {
    27952795        $j = rand( 0, 1 + $hex_encoding );
    2796         if ( $j == 0 ) {
     2796        if ( 0 == $j ) {
    27972797            $email_no_spam_address .= '&#' . ord( $email_address[ $i ] ) . ';';
    2798         } elseif ( $j == 1 ) {
     2798        } elseif ( 1 == $j ) {
    27992799            $email_no_spam_address .= $email_address[ $i ];
    2800         } elseif ( $j == 2 ) {
     2800        } elseif ( 2 == $j ) {
    28012801            $email_no_spam_address .= '%' . zeroise( dechex( ord( $email_address[ $i ] ) ), 2 );
    28022802        }
     
    29392939        }
    29402940
    2941         if ( $nested_code_pre || empty( $piece ) || ( $piece[0] === '<' && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {
     2941        if ( $nested_code_pre || empty( $piece ) || ( '<' === $piece[0] && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {
    29422942            $r .= $piece;
    29432943            continue;
     
    35533553function iso8601_timezone_to_offset( $timezone ) {
    35543554    // $timezone is either 'Z' or '[+|-]hhmm'.
    3555     if ( $timezone == 'Z' ) {
     3555    if ( 'Z' === $timezone ) {
    35563556        $offset = 0;
    35573557    } else {
     
    46274627        case 'default_comment_status':
    46284628            // Options that if not there have 0 value but need to be something like "closed".
    4629             if ( $value == '0' || $value == '' ) {
     4629            if ( '0' == $value || '' == $value ) {
    46304630                $value = 'closed';
    46314631            }
     
    49734973
    49744974        // Fragment has a specifier.
    4975         if ( $pattern[ $start ] == '%' ) {
     4975        if ( '%' === $pattern[ $start ] ) {
    49764976            // Find numbered arguments or take the next one in order.
    49774977            if ( preg_match( '/^%(\d+)\$/', $fragment, $matches ) ) {
Note: See TracChangeset for help on using the changeset viewer.