Skip to content

Commit

Permalink
Coding Standards: Use strict comparison where count() is involved.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
SergeyBiryukov committed Apr 10, 2023
1 parent 0008d8d commit bdfe3d5
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions wp-admin/includes/class-wp-importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function get_imported_posts( $importer_name, $blog_id ) {
$hashtable[ $r->meta_value ] = (int) $r->post_id;
}
}
} while ( count( $results ) == $limit );
} while ( count( $results ) === $limit );

return $hashtable;
}
Expand Down Expand Up @@ -110,7 +110,7 @@ public function get_imported_comments( $blog_id ) {
}
}
}
} while ( count( $results ) == $limit );
} while ( count( $results ) === $limit );

return $hashtable;
}
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/includes/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/class-wp-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -2252,7 +2252,7 @@ public function get_posts() {
}
if ( ! $post_type ) {
$post_type = 'any';
} elseif ( count( $post_type ) == 1 ) {
} elseif ( count( $post_type ) === 1 ) {
$post_type = $post_type[0];
}

Expand Down
2 changes: 1 addition & 1 deletion wp-includes/class-wp-rewrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ public function rewrite_rules() {
// 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'] );
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/class-wp-xmlrpc-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -4243,7 +4243,7 @@ public function wp_getOptions( $args ) {
}

// 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 );
}

Expand Down
2 changes: 1 addition & 1 deletion wp-includes/deprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions wp-includes/formatting.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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 ] );
}
Expand Down Expand Up @@ -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 '';
}

Expand Down Expand Up @@ -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 );
}

Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4754,7 +4754,7 @@ function smilies_init() {
*/
$wpsmiliestrans = apply_filters( 'smilies', $wpsmiliestrans );

if ( count( $wpsmiliestrans ) == 0 ) {
if ( count( $wpsmiliestrans ) === 0 ) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion wp-includes/kses.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/ms-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', '' );
}
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/pluggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
$recipient_name = '';

if ( preg_match( '/(.*)<(.+)>/', $address, $matches ) ) {
if ( count( $matches ) == 3 ) {
if ( count( $matches ) === 3 ) {
$recipient_name = $matches[1];
$address = $matches[2];
}
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit bdfe3d5

Please sign in to comment.