From f28299d50422286d8b2c021e5405a3b2fec44a22 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 7 May 2023 11:44:21 +0000 Subject: [PATCH] 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 --- wp-includes/compat.php | 8 ++++++-- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/wp-includes/compat.php b/wp-includes/compat.php index b2017b9a08..f9df28eac9 100644 --- a/wp-includes/compat.php +++ b/wp-includes/compat.php @@ -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 ); } } diff --git a/wp-includes/version.php b/wp-includes/version.php index fd280cb8ce..0e50c7a078 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.