WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/16/2020 06:40:52 PM (11 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison where static strings are involved.

This reduces the number of WordPress.PHP.StrictComparisons.LooseComparison issues in half, from 1897 to 890.

Includes minor code layout fixes for better readability.

See #49542.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-user-query.php

    r47550 r47808  
    243243            }
    244244            $this->query_fields = implode( ',', $this->query_fields );
    245         } elseif ( 'all' == $qv['fields'] ) {
     245        } elseif ( 'all' === $qv['fields'] ) {
    246246            $this->query_fields = "$wpdb->users.*";
    247247        } else {
     
    321321        $this->meta_query->parse_query_vars( $qv );
    322322
    323         if ( isset( $qv['who'] ) && 'authors' == $qv['who'] && $blog_id ) {
     323        if ( isset( $qv['who'] ) && 'authors' === $qv['who'] && $blog_id ) {
    324324            $who_query = array(
    325325                'key'     => $wpdb->get_blog_prefix( $blog_id ) . 'user_level',
     
    615615            $this->request = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit";
    616616
    617             if ( is_array( $qv['fields'] ) || 'all' == $qv['fields'] ) {
     617            if ( is_array( $qv['fields'] ) || 'all' === $qv['fields'] ) {
    618618                $this->results = $wpdb->get_results( $this->request );
    619619            } else {
     
    643643        }
    644644
    645         if ( 'all_with_meta' == $qv['fields'] ) {
     645        if ( 'all_with_meta' === $qv['fields'] ) {
    646646            cache_users( $this->results );
    647647
     
    652652
    653653            $this->results = $r;
    654         } elseif ( 'all' == $qv['fields'] ) {
     654        } elseif ( 'all' === $qv['fields'] ) {
    655655            foreach ( $this->results as $key => $user ) {
    656656                $this->results[ $key ] = new WP_User( $user, '', $qv['blog_id'] );
     
    704704
    705705        $searches      = array();
    706         $leading_wild  = ( 'leading' == $wild || 'both' == $wild ) ? '%' : '';
    707         $trailing_wild = ( 'trailing' == $wild || 'both' == $wild ) ? '%' : '';
     706        $leading_wild  = ( 'leading' === $wild || 'both' === $wild ) ? '%' : '';
     707        $trailing_wild = ( 'trailing' === $wild || 'both' === $wild ) ? '%' : '';
    708708        $like          = $leading_wild . $wpdb->esc_like( $string ) . $trailing_wild;
    709709
    710710        foreach ( $cols as $col ) {
    711             if ( 'ID' == $col ) {
     711            if ( 'ID' === $col ) {
    712712                $searches[] = $wpdb->prepare( "$col = %s", $string );
    713713            } else {
     
    761761        } elseif ( in_array( $orderby, array( 'user_login', 'user_nicename', 'user_email', 'user_url', 'user_registered' ), true ) ) {
    762762            $_orderby = $orderby;
    763         } elseif ( 'name' == $orderby || 'display_name' == $orderby ) {
     763        } elseif ( 'name' === $orderby || 'display_name' === $orderby ) {
    764764            $_orderby = 'display_name';
    765         } elseif ( 'post_count' == $orderby ) {
     765        } elseif ( 'post_count' === $orderby ) {
    766766            // @todo Avoid the JOIN.
    767767            $where             = get_posts_by_author_sql( 'post' );
     
    774774            ";
    775775            $_orderby          = 'post_count';
    776         } elseif ( 'ID' == $orderby || 'id' == $orderby ) {
     776        } elseif ( 'ID' === $orderby || 'id' === $orderby ) {
    777777            $_orderby = 'ID';
    778         } elseif ( 'meta_value' == $orderby || $this->get( 'meta_key' ) == $orderby ) {
     778        } elseif ( 'meta_value' === $orderby || $this->get( 'meta_key' ) == $orderby ) {
    779779            $_orderby = "$wpdb->usermeta.meta_value";
    780         } elseif ( 'meta_value_num' == $orderby ) {
     780        } elseif ( 'meta_value_num' === $orderby ) {
    781781            $_orderby = "$wpdb->usermeta.meta_value+0";
    782782        } elseif ( 'include' === $orderby && ! empty( $this->query_vars['include'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.