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.
Built from https://develop.svn.wordpress.org/trunk@55652


git-svn-id: http://core.svn.wordpress.org/trunk@55164 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2023-04-15 12:11:24 +00:00
parent f0352db3e4
commit 4d6f46401f
5 changed files with 12 additions and 8 deletions

View File

@ -898,7 +898,7 @@ function seems_utf8( $str ) {
return false; // Does not match any model.
}
for ( $j = 0; $j < $n; $j++ ) { // n bytes matching 10bbbbbb follow ?
if ( ( ++$i == $length ) || ( ( ord( $str[ $i ] ) & 0xC0 ) != 0x80 ) ) {
if ( ( ++$i === $length ) || ( ( ord( $str[ $i ] ) & 0xC0 ) != 0x80 ) ) {
return false;
}
}
@ -5138,7 +5138,7 @@ function wp_sprintf( $pattern, ...$args ) {
$arg_index = 0;
while ( $len > $start ) {
// Last character: append and break.
if ( strlen( $pattern ) - 1 == $start ) {
if ( strlen( $pattern ) - 1 === $start ) {
$result .= substr( $pattern, -1 );
break;
}

View File

@ -1330,7 +1330,7 @@ function wp_kses_hair( $attr, $allowed_protocols ) {
// Loop through the whole attribute list.
while ( strlen( $attr ) != 0 ) {
while ( strlen( $attr ) !== 0 ) {
$working = 0; // Was the last operation successful?
switch ( $mode ) {

View File

@ -40,7 +40,9 @@ function wp_fix_server_vars() {
$_SERVER = array_merge( $default_server_values, $_SERVER );
// Fix for IIS when running with PHP ISAPI.
if ( empty( $_SERVER['REQUEST_URI'] ) || ( 'cgi-fcgi' !== PHP_SAPI && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) {
if ( empty( $_SERVER['REQUEST_URI'] )
|| ( 'cgi-fcgi' !== PHP_SAPI && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) )
) {
if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) {
// IIS Mod-Rewrite.
@ -71,7 +73,9 @@ function wp_fix_server_vars() {
}
// Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests.
if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) {
if ( isset( $_SERVER['SCRIPT_FILENAME'] )
&& ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) === strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 )
) {
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
}

View File

@ -42,7 +42,7 @@ function get_the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctio
function the_title( $before = '', $after = '', $display = true ) {
$title = get_the_title();
if ( strlen( $title ) == 0 ) {
if ( strlen( $title ) === 0 ) {
return;
}
@ -88,7 +88,7 @@ function the_title_attribute( $args = '' ) {
$title = get_the_title( $parsed_args['post'] );
if ( strlen( $title ) == 0 ) {
if ( strlen( $title ) === 0 ) {
return;
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.3-alpha-55651';
$wp_version = '6.3-alpha-55652';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.