From bdfe3d5a469bff49c0bf8b854dbb514e8eb3625b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 10 Apr 2023 12:56:21 +0000 Subject: [PATCH] Coding Standards: Use strict comparison where `count()` is involved. Follow-up to [1636], [6974], [8114], [10322], [13326], [14760], [18006], [18541], [19743], [23249], [24115], [33359]. Props aristath, poena, afercia, SergeyBiryukov. See #57839. Built from https://develop.svn.wordpress.org/trunk@55642 git-svn-id: http://core.svn.wordpress.org/trunk@55154 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-importer.php | 4 ++-- wp-admin/includes/menu.php | 2 +- wp-includes/class-wp-query.php | 2 +- wp-includes/class-wp-rewrite.php | 2 +- wp-includes/class-wp-xmlrpc-server.php | 2 +- wp-includes/deprecated.php | 2 +- wp-includes/formatting.php | 10 +++++----- wp-includes/functions.php | 2 +- wp-includes/kses.php | 2 +- wp-includes/ms-functions.php | 2 +- wp-includes/pluggable.php | 2 +- wp-includes/post.php | 2 +- wp-includes/template.php | 2 +- wp-includes/version.php | 2 +- 14 files changed, 19 insertions(+), 19 deletions(-) diff --git a/wp-admin/includes/class-wp-importer.php b/wp-admin/includes/class-wp-importer.php index 4804c888b2..07545c6d79 100644 --- a/wp-admin/includes/class-wp-importer.php +++ b/wp-admin/includes/class-wp-importer.php @@ -41,7 +41,7 @@ class WP_Importer { $hashtable[ $r->meta_value ] = (int) $r->post_id; } } - } while ( count( $results ) == $limit ); + } while ( count( $results ) === $limit ); return $hashtable; } @@ -110,7 +110,7 @@ class WP_Importer { } } } - } while ( count( $results ) == $limit ); + } while ( count( $results ) === $limit ); return $hashtable; } diff --git a/wp-admin/includes/menu.php b/wp-admin/includes/menu.php index 07c382b989..8412284fd4 100644 --- a/wp-admin/includes/menu.php +++ b/wp-admin/includes/menu.php @@ -241,7 +241,7 @@ function add_menu_classes( $menu ) { $first_item = false; } - if ( $i == $items_count ) { // Last item. + if ( $i === $items_count ) { // Last item. $classes = $menu[ $order ][4]; $menu[ $order ][4] = add_cssclass( 'menu-top-last', $classes ); } diff --git a/wp-includes/class-wp-query.php b/wp-includes/class-wp-query.php index 02baa6d1f1..38d76a73d2 100644 --- a/wp-includes/class-wp-query.php +++ b/wp-includes/class-wp-query.php @@ -2252,7 +2252,7 @@ class WP_Query { } if ( ! $post_type ) { $post_type = 'any'; - } elseif ( count( $post_type ) == 1 ) { + } elseif ( count( $post_type ) === 1 ) { $post_type = $post_type[0]; } diff --git a/wp-includes/class-wp-rewrite.php b/wp-includes/class-wp-rewrite.php index 7288d0ef57..1f42f838bc 100644 --- a/wp-includes/class-wp-rewrite.php +++ b/wp-includes/class-wp-rewrite.php @@ -1399,7 +1399,7 @@ class WP_Rewrite { // Extra permastructs. foreach ( $this->extra_permastructs as $permastructname => $struct ) { if ( is_array( $struct ) ) { - if ( count( $struct ) == 2 ) { + if ( count( $struct ) === 2 ) { $rules = $this->generate_rewrite_rules( $struct[0], $struct[1] ); } else { $rules = $this->generate_rewrite_rules( $struct['struct'], $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints'] ); diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php index f43624d1ec..1220a5c69b 100644 --- a/wp-includes/class-wp-xmlrpc-server.php +++ b/wp-includes/class-wp-xmlrpc-server.php @@ -4243,7 +4243,7 @@ class wp_xmlrpc_server extends IXR_Server { } // If no specific options where asked for, return all of them. - if ( count( $options ) == 0 ) { + if ( count( $options ) === 0 ) { $options = array_keys( $this->blog_options ); } diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index ffc26afdb1..4ec2354f29 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -2297,7 +2297,7 @@ function get_usermeta( $user_id, $meta_key = '' ) { $metas = array_map('maybe_unserialize', $metas); - if ( count($metas) == 1 ) + if ( count($metas) === 1 ) return $metas[0]; else return $metas; diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 40c04c2c4f..1f8a51b97c 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -1169,7 +1169,7 @@ function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = $unicode .= $encoded_char; $unicode_length += $encoded_char_length; } else { - if ( count( $values ) == 0 ) { + if ( count( $values ) === 0 ) { if ( $value < 224 ) { $num_octets = 2; } elseif ( $value < 240 ) { @@ -1184,7 +1184,7 @@ function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = if ( $length && ( $unicode_length + ( $num_octets * 3 ) ) > $length ) { break; } - if ( count( $values ) == $num_octets ) { + if ( count( $values ) === $num_octets ) { for ( $j = 0; $j < $num_octets; $j++ ) { $unicode .= '%' . dechex( $values[ $j ] ); } @@ -3391,7 +3391,7 @@ function wp_remove_targeted_link_rel_filters() { function translate_smiley( $matches ) { global $wpsmiliestrans; - if ( count( $matches ) == 0 ) { + if ( count( $matches ) === 0 ) { return ''; } @@ -5242,7 +5242,7 @@ function wp_sprintf_l( $pattern, $args ) { $args = (array) $args; $result = array_shift( $args ); - if ( count( $args ) == 1 ) { + if ( count( $args ) === 1 ) { $result .= $l['between_only_two'] . array_shift( $args ); } @@ -5251,7 +5251,7 @@ function wp_sprintf_l( $pattern, $args ) { while ( $i ) { $arg = array_shift( $args ); $i--; - if ( 0 == $i ) { + if ( 0 === $i ) { $result .= $l['between_last_two'] . $arg; } else { $result .= $l['between'] . $arg; diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 2af752677d..37540ff571 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -4754,7 +4754,7 @@ function smilies_init() { */ $wpsmiliestrans = apply_filters( 'smilies', $wpsmiliestrans ); - if ( count( $wpsmiliestrans ) == 0 ) { + if ( count( $wpsmiliestrans ) === 0 ) { return; } diff --git a/wp-includes/kses.php b/wp-includes/kses.php index 6bbb7c977d..95d9c65cae 100644 --- a/wp-includes/kses.php +++ b/wp-includes/kses.php @@ -788,7 +788,7 @@ function wp_kses_one_attr( $attr, $element ) { // Parse attribute name and value from input. $split = preg_split( '/\s*=\s*/', $attr, 2 ); $name = $split[0]; - if ( count( $split ) == 2 ) { + if ( count( $split ) === 2 ) { $value = $split[1]; // Remove quotes surrounding $value. diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index e6cbc32cb0..9f39266231 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -274,7 +274,7 @@ function remove_user_from_blog( $user_id, $blog_id = 0, $reassign = 0 ) { $user->remove_all_caps(); $blogs = get_blogs_of_user( $user_id ); - if ( count( $blogs ) == 0 ) { + if ( count( $blogs ) === 0 ) { update_user_meta( $user_id, 'primary_blog', '' ); update_user_meta( $user_id, 'source_domain', '' ); } diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index bbf4d43947..8081f9e62c 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -432,7 +432,7 @@ if ( ! function_exists( 'wp_mail' ) ) : $recipient_name = ''; if ( preg_match( '/(.*)<(.+)>/', $address, $matches ) ) { - if ( count( $matches ) == 3 ) { + if ( count( $matches ) === 3 ) { $recipient_name = $matches[1]; $address = $matches[2]; } diff --git a/wp-includes/post.php b/wp-includes/post.php index c411dcc371..7dc67105e1 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -5732,7 +5732,7 @@ function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) { $p = $parent; } - if ( 0 == $p->post_parent && count( $revparts ) == $count + 1 && $p->post_name == $revparts[ $count ] ) { + if ( 0 == $p->post_parent && count( $revparts ) === $count + 1 && $p->post_name == $revparts[ $count ] ) { $foundid = $page->ID; if ( $page->post_type == $post_type ) { break; diff --git a/wp-includes/template.php b/wp-includes/template.php index e571a6a141..f071881d49 100644 --- a/wp-includes/template.php +++ b/wp-includes/template.php @@ -152,7 +152,7 @@ function get_archive_template() { $templates = array(); - if ( count( $post_types ) == 1 ) { + if ( count( $post_types ) === 1 ) { $post_type = reset( $post_types ); $templates[] = "archive-{$post_type}.php"; } diff --git a/wp-includes/version.php b/wp-includes/version.php index bd69b0e074..5a21f8b15b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-alpha-55641'; +$wp_version = '6.3-alpha-55642'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.