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-term-query.php

    r46652 r47808  
    254254        }
    255255
    256         if ( 'all' == $query['get'] ) {
     256        if ( 'all' === $query['get'] ) {
    257257            $query['childless']    = false;
    258258            $query['child_of']     = 0;
     
    342342        }
    343343
    344         if ( 'all' == $args['get'] ) {
     344        if ( 'all' === $args['get'] ) {
    345345            $args['childless']    = false;
    346346            $args['child_of']     = 0;
     
    383383
    384384            if ( ! $in_hierarchy ) {
    385                 if ( 'count' == $args['fields'] ) {
     385                if ( 'count' === $args['fields'] ) {
    386386                    return 0;
    387387                } else {
     
    546546
    547547        $hierarchical = $args['hierarchical'];
    548         if ( 'count' == $args['fields'] ) {
     548        if ( 'count' === $args['fields'] ) {
    549549            $hierarchical = false;
    550550        }
     
    710710        }
    711711
    712         if ( 'count' == $_fields ) {
     712        if ( 'count' === $_fields ) {
    713713            $count = $wpdb->get_var( $this->request );
    714714            wp_cache_set( $cache_key, $count, 'terms' );
     
    717717
    718718        $terms = $wpdb->get_results( $this->request );
    719         if ( 'all' == $_fields || 'all_with_object_id' === $_fields ) {
     719
     720        if ( 'all' === $_fields || 'all_with_object_id' === $_fields ) {
    720721            update_term_cache( $terms );
    721722        }
     
    742743
    743744        // Update term counts to include children.
    744         if ( $args['pad_counts'] && 'all' == $_fields ) {
     745        if ( $args['pad_counts'] && 'all' === $_fields ) {
    745746            foreach ( $taxonomies as $_tax ) {
    746747                _pad_term_counts( $terms, $_tax );
     
    774775         * removed.
    775776         */
    776         if ( ! empty( $args['object_ids'] ) && 'all_with_object_id' != $_fields ) {
     777        if ( ! empty( $args['object_ids'] ) && 'all_with_object_id' !== $_fields ) {
    777778            $_tt_ids = array();
    778779            $_terms  = array();
     
    790791
    791792        $_terms = array();
    792         if ( 'id=>parent' == $_fields ) {
     793        if ( 'id=>parent' === $_fields ) {
    793794            foreach ( $terms as $term ) {
    794795                $_terms[ $term->term_id ] = $term->parent;
    795796            }
    796         } elseif ( 'ids' == $_fields ) {
     797        } elseif ( 'ids' === $_fields ) {
    797798            foreach ( $terms as $term ) {
    798799                $_terms[] = (int) $term->term_id;
    799800            }
    800         } elseif ( 'tt_ids' == $_fields ) {
     801        } elseif ( 'tt_ids' === $_fields ) {
    801802            foreach ( $terms as $term ) {
    802803                $_terms[] = (int) $term->term_taxonomy_id;
    803804            }
    804         } elseif ( 'names' == $_fields ) {
     805        } elseif ( 'names' === $_fields ) {
    805806            foreach ( $terms as $term ) {
    806807                $_terms[] = $term->name;
    807808            }
    808         } elseif ( 'slugs' == $_fields ) {
     809        } elseif ( 'slugs' === $_fields ) {
    809810            foreach ( $terms as $term ) {
    810811                $_terms[] = $term->slug;
    811812            }
    812         } elseif ( 'id=>name' == $_fields ) {
     813        } elseif ( 'id=>name' === $_fields ) {
    813814            foreach ( $terms as $term ) {
    814815                $_terms[ $term->term_id ] = $term->name;
    815816            }
    816         } elseif ( 'id=>slug' == $_fields ) {
     817        } elseif ( 'id=>slug' === $_fields ) {
    817818            foreach ( $terms as $term ) {
    818819                $_terms[ $term->term_id ] = $term->slug;
     
    863864        } elseif ( 'term_order' === $_orderby ) {
    864865            $orderby = 'tr.term_order';
    865         } elseif ( 'include' == $_orderby && ! empty( $this->query_vars['include'] ) ) {
     866        } elseif ( 'include' === $_orderby && ! empty( $this->query_vars['include'] ) ) {
    866867            $include = implode( ',', wp_parse_id_list( $this->query_vars['include'] ) );
    867868            $orderby = "FIELD( t.term_id, $include )";
    868         } elseif ( 'slug__in' == $_orderby && ! empty( $this->query_vars['slug'] ) && is_array( $this->query_vars['slug'] ) ) {
     869        } elseif ( 'slug__in' === $_orderby && ! empty( $this->query_vars['slug'] ) && is_array( $this->query_vars['slug'] ) ) {
    869870            $slugs   = implode( "', '", array_map( 'sanitize_title_for_query', $this->query_vars['slug'] ) );
    870871            $orderby = "FIELD( t.slug, '" . $slugs . "')";
    871         } elseif ( 'none' == $_orderby ) {
     872        } elseif ( 'none' === $_orderby ) {
    872873            $orderby = '';
    873         } elseif ( empty( $_orderby ) || 'id' == $_orderby || 'term_id' === $_orderby ) {
     874        } elseif ( empty( $_orderby ) || 'id' === $_orderby || 'term_id' === $_orderby ) {
    874875            $orderby = 't.term_id';
    875876        } else {
Note: See TracChangeset for help on using the changeset viewer.