Make WordPress Core

Changeset 61053


Ignore:
Timestamp:
10/22/2025 11:23:50 PM (10 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

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

    r60913 r61053  
    447447        $pre_tags = array();
    448448
    449         if ( trim( $text ) === '' ) {
     449        if ( '' === trim( $text ) ) {
    450450                return '';
    451451        }
     
    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;
     
    25592559 */
    25602560function 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 {
     
    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 );
     
    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        }
     
    34473447        global $wpsmiliestrans;
    34483448
    3449         if ( count( $matches ) === 0 ) {
     3449        if ( 0 === count( $matches ) ) {
    34503450                return '';
    34513451        }
     
    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' );
     
    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' );
     
    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        }
Note: See TracChangeset for help on using the changeset viewer.