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
This commit is contained in:
Sergey Biryukov 2023-04-10 12:56:21 +00:00
parent 0008d8df06
commit bdfe3d5a46
14 changed files with 19 additions and 19 deletions

View File

@ -41,7 +41,7 @@ class WP_Importer {
$hashtable[ $r->meta_value ] = (int) $r->post_id; $hashtable[ $r->meta_value ] = (int) $r->post_id;
} }
} }
} while ( count( $results ) == $limit ); } while ( count( $results ) === $limit );
return $hashtable; return $hashtable;
} }
@ -110,7 +110,7 @@ class WP_Importer {
} }
} }
} }
} while ( count( $results ) == $limit ); } while ( count( $results ) === $limit );
return $hashtable; return $hashtable;
} }

View File

@ -241,7 +241,7 @@ function add_menu_classes( $menu ) {
$first_item = false; $first_item = false;
} }
if ( $i == $items_count ) { // Last item. if ( $i === $items_count ) { // Last item.
$classes = $menu[ $order ][4]; $classes = $menu[ $order ][4];
$menu[ $order ][4] = add_cssclass( 'menu-top-last', $classes ); $menu[ $order ][4] = add_cssclass( 'menu-top-last', $classes );
} }

View File

@ -2252,7 +2252,7 @@ class WP_Query {
} }
if ( ! $post_type ) { if ( ! $post_type ) {
$post_type = 'any'; $post_type = 'any';
} elseif ( count( $post_type ) == 1 ) { } elseif ( count( $post_type ) === 1 ) {
$post_type = $post_type[0]; $post_type = $post_type[0];
} }

View File

@ -1399,7 +1399,7 @@ class WP_Rewrite {
// Extra permastructs. // Extra permastructs.
foreach ( $this->extra_permastructs as $permastructname => $struct ) { foreach ( $this->extra_permastructs as $permastructname => $struct ) {
if ( is_array( $struct ) ) { if ( is_array( $struct ) ) {
if ( count( $struct ) == 2 ) { if ( count( $struct ) === 2 ) {
$rules = $this->generate_rewrite_rules( $struct[0], $struct[1] ); $rules = $this->generate_rewrite_rules( $struct[0], $struct[1] );
} else { } else {
$rules = $this->generate_rewrite_rules( $struct['struct'], $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints'] ); $rules = $this->generate_rewrite_rules( $struct['struct'], $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints'] );

View File

@ -4243,7 +4243,7 @@ class wp_xmlrpc_server extends IXR_Server {
} }
// If no specific options where asked for, return all of them. // 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 ); $options = array_keys( $this->blog_options );
} }

View File

@ -2297,7 +2297,7 @@ function get_usermeta( $user_id, $meta_key = '' ) {
$metas = array_map('maybe_unserialize', $metas); $metas = array_map('maybe_unserialize', $metas);
if ( count($metas) == 1 ) if ( count($metas) === 1 )
return $metas[0]; return $metas[0];
else else
return $metas; return $metas;

View File

@ -1169,7 +1169,7 @@ function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters =
$unicode .= $encoded_char; $unicode .= $encoded_char;
$unicode_length += $encoded_char_length; $unicode_length += $encoded_char_length;
} else { } else {
if ( count( $values ) == 0 ) { if ( count( $values ) === 0 ) {
if ( $value < 224 ) { if ( $value < 224 ) {
$num_octets = 2; $num_octets = 2;
} elseif ( $value < 240 ) { } 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 ) { if ( $length && ( $unicode_length + ( $num_octets * 3 ) ) > $length ) {
break; break;
} }
if ( count( $values ) == $num_octets ) { if ( count( $values ) === $num_octets ) {
for ( $j = 0; $j < $num_octets; $j++ ) { for ( $j = 0; $j < $num_octets; $j++ ) {
$unicode .= '%' . dechex( $values[ $j ] ); $unicode .= '%' . dechex( $values[ $j ] );
} }
@ -3391,7 +3391,7 @@ function wp_remove_targeted_link_rel_filters() {
function translate_smiley( $matches ) { function translate_smiley( $matches ) {
global $wpsmiliestrans; global $wpsmiliestrans;
if ( count( $matches ) == 0 ) { if ( count( $matches ) === 0 ) {
return ''; return '';
} }
@ -5242,7 +5242,7 @@ function wp_sprintf_l( $pattern, $args ) {
$args = (array) $args; $args = (array) $args;
$result = array_shift( $args ); $result = array_shift( $args );
if ( count( $args ) == 1 ) { if ( count( $args ) === 1 ) {
$result .= $l['between_only_two'] . array_shift( $args ); $result .= $l['between_only_two'] . array_shift( $args );
} }
@ -5251,7 +5251,7 @@ function wp_sprintf_l( $pattern, $args ) {
while ( $i ) { while ( $i ) {
$arg = array_shift( $args ); $arg = array_shift( $args );
$i--; $i--;
if ( 0 == $i ) { if ( 0 === $i ) {
$result .= $l['between_last_two'] . $arg; $result .= $l['between_last_two'] . $arg;
} else { } else {
$result .= $l['between'] . $arg; $result .= $l['between'] . $arg;

View File

@ -4754,7 +4754,7 @@ function smilies_init() {
*/ */
$wpsmiliestrans = apply_filters( 'smilies', $wpsmiliestrans ); $wpsmiliestrans = apply_filters( 'smilies', $wpsmiliestrans );
if ( count( $wpsmiliestrans ) == 0 ) { if ( count( $wpsmiliestrans ) === 0 ) {
return; return;
} }

View File

@ -788,7 +788,7 @@ function wp_kses_one_attr( $attr, $element ) {
// Parse attribute name and value from input. // Parse attribute name and value from input.
$split = preg_split( '/\s*=\s*/', $attr, 2 ); $split = preg_split( '/\s*=\s*/', $attr, 2 );
$name = $split[0]; $name = $split[0];
if ( count( $split ) == 2 ) { if ( count( $split ) === 2 ) {
$value = $split[1]; $value = $split[1];
// Remove quotes surrounding $value. // Remove quotes surrounding $value.

View File

@ -274,7 +274,7 @@ function remove_user_from_blog( $user_id, $blog_id = 0, $reassign = 0 ) {
$user->remove_all_caps(); $user->remove_all_caps();
$blogs = get_blogs_of_user( $user_id ); $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, 'primary_blog', '' );
update_user_meta( $user_id, 'source_domain', '' ); update_user_meta( $user_id, 'source_domain', '' );
} }

View File

@ -432,7 +432,7 @@ if ( ! function_exists( 'wp_mail' ) ) :
$recipient_name = ''; $recipient_name = '';
if ( preg_match( '/(.*)<(.+)>/', $address, $matches ) ) { if ( preg_match( '/(.*)<(.+)>/', $address, $matches ) ) {
if ( count( $matches ) == 3 ) { if ( count( $matches ) === 3 ) {
$recipient_name = $matches[1]; $recipient_name = $matches[1];
$address = $matches[2]; $address = $matches[2];
} }

View File

@ -5732,7 +5732,7 @@ function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) {
$p = $parent; $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; $foundid = $page->ID;
if ( $page->post_type == $post_type ) { if ( $page->post_type == $post_type ) {
break; break;

View File

@ -152,7 +152,7 @@ function get_archive_template() {
$templates = array(); $templates = array();
if ( count( $post_types ) == 1 ) { if ( count( $post_types ) === 1 ) {
$post_type = reset( $post_types ); $post_type = reset( $post_types );
$templates[] = "archive-{$post_type}.php"; $templates[] = "archive-{$post_type}.php";
} }

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @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. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.