Coding Standards: Bring more consistency to PHP 8.0 string function polyfills.

This adjusts `str_contains()` code layout to have an early exit for an empty `$needle`, matching similar fragments in `str_starts_with()` and `str_ends_with()` for better readability.

Follow-up to [52039], [52040].

See #57839.
Built from https://develop.svn.wordpress.org/trunk@55726


git-svn-id: http://core.svn.wordpress.org/trunk@55238 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2023-05-07 11:44:21 +00:00
parent 8b53b81183
commit f28299d504
2 changed files with 7 additions and 3 deletions

View File

@ -434,11 +434,15 @@ if ( ! function_exists( 'str_contains' ) ) {
* @since 5.9.0
*
* @param string $haystack The string to search in.
* @param string $needle The substring to search for in the haystack.
* @param string $needle The substring to search for in the `$haystack`.
* @return bool True if `$needle` is in `$haystack`, otherwise false.
*/
function str_contains( $haystack, $needle ) {
return ( '' === $needle || false !== strpos( $haystack, $needle ) );
if ( '' === $needle ) {
return true;
}
return false !== strpos( $haystack, $needle );
}
}

View File

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