Make WordPress Core


Ignore:
Timestamp:
02/09/2020 04:52:28 PM (6 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/functions.php

    r47212 r47219  
    687687        } elseif ( ';' !== substr( $data, -1 ) ) {
    688688                return false;
    689         } elseif ( $data[0] !== 's' ) {
     689        } elseif ( 's' !== $data[0] ) {
    690690                return false;
    691691        } elseif ( '"' !== substr( $data, -2, 1 ) ) {
     
    10141014                        $k = urlencode( $k );
    10151015                }
    1016                 if ( is_int( $k ) && $prefix != null ) {
     1016                if ( is_int( $k ) && null != $prefix ) {
    10171017                        $k = $prefix . $k;
    10181018                }
     
    10201020                        $k = $key . '%5B' . $k . '%5D';
    10211021                }
    1022                 if ( $v === null ) {
     1022                if ( null === $v ) {
    10231023                        continue;
    1024                 } elseif ( $v === false ) {
     1024                } elseif ( false === $v ) {
    10251025                        $v = '0';
    10261026                }
     
    11331133
    11341134        foreach ( $qs as $k => $v ) {
    1135                 if ( $v === false ) {
     1135                if ( false === $v ) {
    11361136                        unset( $qs[ $k ] );
    11371137                }
     
    15401540        $feed = preg_replace( '/^_+/', '', $feed );
    15411541
    1542         if ( $feed == '' || $feed == 'feed' ) {
     1542        if ( '' == $feed || 'feed' === $feed ) {
    15431543                $feed = get_default_feed();
    15441544        }
     
    18861886        $ref = wp_get_raw_referer();
    18871887
    1888         if ( $ref && $ref !== wp_unslash( $_SERVER['REQUEST_URI'] ) && $ref !== home_url() . wp_unslash( $_SERVER['REQUEST_URI'] ) ) {
     1888        if ( $ref && wp_unslash( $_SERVER['REQUEST_URI'] ) !== $ref && home_url() . wp_unslash( $_SERVER['REQUEST_URI'] ) !== $ref ) {
    18891889                return wp_validate_redirect( $ref, false );
    18901890        }
     
    19481948
    19491949        // Put the wrapper back on the target.
    1950         if ( $wrapper !== null ) {
     1950        if ( null !== $wrapper ) {
    19511951                $target = $wrapper . '://' . $target;
    19521952        }
     
    19901990                 * the $dir_perms correctly with chmod()
    19911991                 */
    1992                 if ( $dir_perms != ( $dir_perms & ~umask() ) ) {
     1992                if ( ( $dir_perms & ~umask() ) != $dir_perms ) {
    19931993                        $folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) );
    19941994                        for ( $i = 1, $c = count( $folder_parts ); $i <= $c; $i++ ) {
     
    20302030        }
    20312031
    2032         if ( strlen( $path ) == 0 || $path[0] == '.' ) {
     2032        if ( strlen( $path ) == 0 || '.' === $path[0] ) {
    20332033                return false;
    20342034        }
     
    20402040
    20412041        // A path starting with / or \ is absolute; anything else is relative.
    2042         return ( $path[0] == '/' || $path[0] == '\\' );
     2042        return ( '/' === $path[0] || '\\' === $path[0] );
    20432043}
    20442044
     
    21862186 */
    21872187function win_is_writable( $path ) {
    2188         if ( $path[ strlen( $path ) - 1 ] == '/' ) {
     2188        if ( '/' === $path[ strlen( $path ) - 1 ] ) {
    21892189                // If it looks like a directory, check a random file within the directory.
    21902190                return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp' );
     
    21982198
    21992199        $f = @fopen( $path, 'a' );
    2200         if ( $f === false ) {
     2200        if ( false === $f ) {
    22012201                return false;
    22022202        }
     
    26342634        $upload = wp_upload_dir( $time );
    26352635
    2636         if ( $upload['error'] !== false ) {
     2636        if ( false !== $upload['error'] ) {
    26372637                return $upload;
    26382638        }
     
    43224322                // New subpattern?
    43234323                if ( $firstchar != $subchar ) {
    4324                         if ( $subchar != '' ) {
     4324                        if ( '' != $subchar ) {
    43254325                                $wp_smiliessearch .= ')(?=' . $spaces . '|$)';  // End previous "subpattern".
    43264326                                $wp_smiliessearch .= '|(?<=' . $spaces . '|^)'; // Begin another "subpattern".
     
    54625462        $site_id = (int) $site_id;
    54635463
    5464         return $site_id === get_main_site_id( $network_id );
     5464        return get_main_site_id( $network_id ) === $site_id;
    54655465}
    54665466
     
    55065506        $network_id = (int) $network_id;
    55075507
    5508         return ( $network_id === get_main_network_id() );
     5508        return ( get_main_network_id() === $network_id );
    55095509}
    55105510
     
    75147514        }
    75157515
    7516         if ( $max_execution_time === null ) {
     7516        if ( null === $max_execution_time ) {
    75177517                // Keep the previous behavior but attempt to prevent fatal errors from timeout if possible.
    75187518                if ( function_exists( 'ini_get' ) ) {
     
    75337533                while ( ( $file = readdir( $handle ) ) !== false ) {
    75347534                        $path = $directory . '/' . $file;
    7535                         if ( $file != '.' && $file != '..' ) {
     7535                        if ( '.' !== $file && '..' !== $file ) {
    75367536                                if ( is_file( $path ) ) {
    75377537                                        $size += filesize( $path );
Note: See TracChangeset for help on using the changeset viewer.