Coding Standards: Use Yoda conditions where appropriate.

See #49222.
Built from https://develop.svn.wordpress.org/trunk@47219


git-svn-id: http://core.svn.wordpress.org/trunk@47019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov
2020-02-09 16:55:09 +00:00
parent 5e6c949861
commit 641c632b0c
125 changed files with 555 additions and 555 deletions

View File

@@ -479,7 +479,7 @@ function wpautop( $pee, $br = true ) {
$start = strpos( $pee_part, '<pre' );
// Malformed HTML?
if ( $start === false ) {
if ( false === $start ) {
$pee .= $pee_part;
continue;
}
@@ -984,10 +984,10 @@ function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = fals
$_quote_style = $quote_style;
if ( $quote_style === 'double' ) {
if ( 'double' === $quote_style ) {
$quote_style = ENT_COMPAT;
$_quote_style = ENT_COMPAT;
} elseif ( $quote_style === 'single' ) {
} elseif ( 'single' === $quote_style ) {
$quote_style = ENT_NOQUOTES;
}
@@ -1080,16 +1080,16 @@ function wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES ) {
'/&#x0*26;/i' => '&#x26;',
);
if ( $quote_style === ENT_QUOTES ) {
if ( ENT_QUOTES === $quote_style ) {
$translation = array_merge( $single, $double, $others );
$translation_preg = array_merge( $single_preg, $double_preg, $others_preg );
} elseif ( $quote_style === ENT_COMPAT || $quote_style === 'double' ) {
} elseif ( ENT_COMPAT === $quote_style || 'double' === $quote_style ) {
$translation = array_merge( $double, $others );
$translation_preg = array_merge( $double_preg, $others_preg );
} elseif ( $quote_style === 'single' ) {
} elseif ( 'single' === $quote_style ) {
$translation = array_merge( $single, $others );
$translation_preg = array_merge( $single_preg, $others_preg );
} elseif ( $quote_style === ENT_NOQUOTES ) {
} elseif ( ENT_NOQUOTES === $quote_style ) {
$translation = $others;
$translation_preg = $others_preg;
}
@@ -2793,11 +2793,11 @@ function antispambot( $email_address, $hex_encoding = 0 ) {
$email_no_spam_address = '';
for ( $i = 0, $len = strlen( $email_address ); $i < $len; $i++ ) {
$j = rand( 0, 1 + $hex_encoding );
if ( $j == 0 ) {
if ( 0 == $j ) {
$email_no_spam_address .= '&#' . ord( $email_address[ $i ] ) . ';';
} elseif ( $j == 1 ) {
} elseif ( 1 == $j ) {
$email_no_spam_address .= $email_address[ $i ];
} elseif ( $j == 2 ) {
} elseif ( 2 == $j ) {
$email_no_spam_address .= '%' . zeroise( dechex( ord( $email_address[ $i ] ) ), 2 );
}
}
@@ -2938,7 +2938,7 @@ function make_clickable( $text ) {
$nested_code_pre--;
}
if ( $nested_code_pre || empty( $piece ) || ( $piece[0] === '<' && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {
if ( $nested_code_pre || empty( $piece ) || ( '<' === $piece[0] && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {
$r .= $piece;
continue;
}
@@ -3552,7 +3552,7 @@ function get_date_from_gmt( $string, $format = 'Y-m-d H:i:s' ) {
*/
function iso8601_timezone_to_offset( $timezone ) {
// $timezone is either 'Z' or '[+|-]hhmm'.
if ( $timezone == 'Z' ) {
if ( 'Z' === $timezone ) {
$offset = 0;
} else {
$sign = ( substr( $timezone, 0, 1 ) == '+' ) ? 1 : -1;
@@ -4626,7 +4626,7 @@ function sanitize_option( $option, $value ) {
case 'default_ping_status':
case 'default_comment_status':
// Options that if not there have 0 value but need to be something like "closed".
if ( $value == '0' || $value == '' ) {
if ( '0' == $value || '' == $value ) {
$value = 'closed';
}
break;
@@ -4972,7 +4972,7 @@ function wp_sprintf( $pattern, ...$args ) {
$fragment = substr( $pattern, $start, $end - $start );
// Fragment has a specifier.
if ( $pattern[ $start ] == '%' ) {
if ( '%' === $pattern[ $start ] ) {
// Find numbered arguments or take the next one in order.
if ( preg_match( '/^%(\d+)\$/', $fragment, $matches ) ) {
$index = $matches[1] - 1; // 0-based array vs 1-based sprintf() arguments.