Skip to content

Commit 760728c

Browse files
Coding Standards: Use strict comparison where strlen() is involved.
Follow-up to [649], [1345], [3034], [6132], [6314], [6974], [55642]. Props aristath, poena, afercia, SergeyBiryukov. See #57839. git-svn-id: https://develop.svn.wordpress.org/trunk@55652 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 94f1eb3 commit 760728c

4 files changed

Lines changed: 11 additions & 7 deletions

File tree

‎src/wp-includes/formatting.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ function seems_utf8( $str ) {
898898
return false; // Does not match any model.
899899
}
900900
for ( $j = 0; $j < $n; $j++ ) { // n bytes matching 10bbbbbb follow ?
901-
if ( ( ++$i == $length ) || ( ( ord( $str[ $i ] ) & 0xC0 ) != 0x80 ) ) {
901+
if ( ( ++$i === $length ) || ( ( ord( $str[ $i ] ) & 0xC0 ) != 0x80 ) ) {
902902
return false;
903903
}
904904
}
@@ -5138,7 +5138,7 @@ function wp_sprintf( $pattern, ...$args ) {
51385138
$arg_index = 0;
51395139
while ( $len > $start ) {
51405140
// Last character: append and break.
5141-
if ( strlen( $pattern ) - 1 == $start ) {
5141+
if ( strlen( $pattern ) - 1 === $start ) {
51425142
$result .= substr( $pattern, -1 );
51435143
break;
51445144
}

‎src/wp-includes/kses.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,7 @@ function wp_kses_hair( $attr, $allowed_protocols ) {
13301330

13311331
// Loop through the whole attribute list.
13321332

1333-
while ( strlen( $attr ) != 0 ) {
1333+
while ( strlen( $attr ) !== 0 ) {
13341334
$working = 0; // Was the last operation successful?
13351335
13361336
switch ( $mode ) {

‎src/wp-includes/load.php‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ function wp_fix_server_vars() {
4040
$_SERVER = array_merge( $default_server_values, $_SERVER );
4141

4242
// Fix for IIS when running with PHP ISAPI.
43-
if ( empty( $_SERVER['REQUEST_URI'] ) || ( 'cgi-fcgi' !== PHP_SAPI && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) {
43+
if ( empty( $_SERVER['REQUEST_URI'] )
44+
|| ( 'cgi-fcgi' !== PHP_SAPI && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) )
45+
) {
4446

4547
if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) {
4648
// IIS Mod-Rewrite.
@@ -71,7 +73,9 @@ function wp_fix_server_vars() {
7173
}
7274

7375
// Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests.
74-
if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) {
76+
if ( isset( $_SERVER['SCRIPT_FILENAME'] )
77+
&& ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) === strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 )
78+
) {
7579
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
7680
}
7781

‎src/wp-includes/post-template.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function get_the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctio
4242
function the_title( $before = '', $after = '', $display = true ) {
4343
$title = get_the_title();
4444

45-
if ( strlen( $title ) == 0 ) {
45+
if ( strlen( $title ) === 0 ) {
4646
return;
4747
}
4848

@@ -88,7 +88,7 @@ function the_title_attribute( $args = '' ) {
8888

8989
$title = get_the_title( $parsed_args['post'] );
9090

91-
if ( strlen( $title ) == 0 ) {
91+
if ( strlen( $title ) === 0 ) {
9292
return;
9393
}
9494

0 commit comments

Comments
 (0)