Skip to content

Commit aae3ac3

Browse files
Coding Standards: Use Yoda conditions consistently in wp-includes/formatting.php.
While Yoda conditions are mostly relevant for variables and not required if neither side is a variable, this commit aims to make the order more consistent throughout the file. Follow-up to [1636], [4990], [6974], [10322], [10769], [11048], [42770], [47219], [56325]. Props subrataemfluence, sabernhardt, ishikaatxecurify, callumbw95, peterwilsoncc, SergeyBiryukov. Fixes #46846. git-svn-id: https://develop.svn.wordpress.org/trunk@61053 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 241357d commit aae3ac3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/wp-includes/formatting.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ function _wptexturize_pushpop_element( $text, &$stack, $disabled_elements ) {
446446
function wpautop( $text, $br = true ) {
447447
$pre_tags = array();
448448

449-
if ( trim( $text ) === '' ) {
449+
if ( '' === trim( $text ) ) {
450450
return '';
451451
}
452452

@@ -1181,7 +1181,7 @@ function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters =
11811181
$unicode .= $encoded_char;
11821182
$unicode_length += $encoded_char_length;
11831183
} else {
1184-
if ( count( $values ) === 0 ) {
1184+
if ( 0 === count( $values ) ) {
11851185
if ( $value < 224 ) {
11861186
$num_octets = 2;
11871187
} elseif ( $value < 240 ) {
@@ -2558,7 +2558,7 @@ function convert_invalid_entities( $content ) {
25582558
* @return string Balanced text.
25592559
*/
25602560
function balanceTags( $text, $force = false ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
2561-
if ( $force || (int) get_option( 'use_balanceTags' ) === 1 ) {
2561+
if ( $force || 1 === (int) get_option( 'use_balanceTags' ) ) {
25622562
return force_balance_tags( $text );
25632563
} else {
25642564
return $text;
@@ -2999,7 +2999,7 @@ function _make_web_ftp_clickable_cb( $matches ) {
29992999

30003000
// Removed trailing [.,;:)] from URL.
30013001
$last_char = substr( $dest, -1 );
3002-
if ( in_array( $last_char, array( '.', ',', ';', ':', ')' ), true ) === true ) {
3002+
if ( in_array( $last_char, array( '.', ',', ';', ':', ')' ), true ) ) {
30033003
$ret = $last_char;
30043004
$dest = substr( $dest, 0, strlen( $dest ) - 1 );
30053005
}
@@ -3326,7 +3326,7 @@ function wp_targeted_link_rel( $text ) {
33263326
_deprecated_function( __FUNCTION__, '6.7.0' );
33273327

33283328
// Don't run (more expensive) regex if no links with targets.
3329-
if ( stripos( $text, 'target' ) === false || stripos( $text, '<a ' ) === false || is_serialized( $text ) ) {
3329+
if ( false === stripos( $text, 'target' ) || false === stripos( $text, '<a ' ) || is_serialized( $text ) ) {
33303330
return $text;
33313331
}
33323332

@@ -3446,7 +3446,7 @@ function wp_remove_targeted_link_rel_filters() {
34463446
function translate_smiley( $matches ) {
34473447
global $wpsmiliestrans;
34483448

3449-
if ( count( $matches ) === 0 ) {
3449+
if ( 0 === count( $matches ) ) {
34503450
return '';
34513451
}
34523452

@@ -3572,7 +3572,7 @@ function is_email( $email, $deprecated = false ) {
35723572
}
35733573

35743574
// Test for an @ character after the first position.
3575-
if ( strpos( $email, '@', 1 ) === false ) {
3575+
if ( false === strpos( $email, '@', 1 ) ) {
35763576
/** This filter is documented in wp-includes/formatting.php */
35773577
return apply_filters( 'is_email', false, $email, 'email_no_at' );
35783578
}
@@ -3786,7 +3786,7 @@ function sanitize_email( $email ) {
37863786
}
37873787

37883788
// Test for an @ character after the first position.
3789-
if ( strpos( $email, '@', 1 ) === false ) {
3789+
if ( false === strpos( $email, '@', 1 ) ) {
37903790
/** This filter is documented in wp-includes/formatting.php */
37913791
return apply_filters( 'sanitize_email', '', $email, 'email_no_at' );
37923792
}
@@ -5362,7 +5362,7 @@ function wp_sprintf_l( $pattern, $args ) {
53625362

53635363
$args = (array) $args;
53645364
$result = array_shift( $args );
5365-
if ( count( $args ) === 1 ) {
5365+
if ( 1 === count( $args ) ) {
53665366
$result .= $l['between_only_two'] . array_shift( $args );
53675367
}
53685368

0 commit comments

Comments
 (0)