From f51ef1dabeef9036fc62eeb5a9e1b8a8f31dcc81 Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Tue, 30 Jan 2024 18:16:03 +0000 Subject: [PATCH] General: Fix nesting in compat.php. Follow up to [57451]. Built from https://develop.svn.wordpress.org/branches/5.7@57456 git-svn-id: http://core.svn.wordpress.org/branches/5.7@56957 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/compat.php | 84 +++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/wp-includes/compat.php b/wp-includes/compat.php index 319cff6f74..3545d38a6b 100644 --- a/wp-includes/compat.php +++ b/wp-includes/compat.php @@ -369,50 +369,50 @@ if ( ! function_exists( 'is_iterable' ) ) { function is_iterable( $var ) { return ( is_array( $var ) || $var instanceof Traversable ); } +} - if ( ! function_exists( 'str_starts_with' ) ) { - /** - * Polyfill for `str_starts_with()` function added in PHP 8.0. - * - * Performs a case-sensitive check indicating if - * the haystack begins with needle. - * - * @since 5.9.0 - * - * @param string $haystack The string to search in. - * @param string $needle The substring to search for in the `$haystack`. - * @return bool True if `$haystack` starts with `$needle`, otherwise false. - */ - function str_starts_with( $haystack, $needle ) { - if ( '' === $needle ) { - return true; - } - - return 0 === strpos( $haystack, $needle ); +if ( ! function_exists( 'str_starts_with' ) ) { + /** + * Polyfill for `str_starts_with()` function added in PHP 8.0. + * + * Performs a case-sensitive check indicating if + * the haystack begins with needle. + * + * @since 5.9.0 + * + * @param string $haystack The string to search in. + * @param string $needle The substring to search for in the `$haystack`. + * @return bool True if `$haystack` starts with `$needle`, otherwise false. + */ + function str_starts_with( $haystack, $needle ) { + if ( '' === $needle ) { + return true; } - } - if ( ! function_exists( 'str_ends_with' ) ) { - /** - * Polyfill for `str_ends_with()` function added in PHP 8.0. - * - * Performs a case-sensitive check indicating if - * the haystack ends with needle. - * - * @since 5.9.0 - * - * @param string $haystack The string to search in. - * @param string $needle The substring to search for in the `$haystack`. - * @return bool True if `$haystack` ends with `$needle`, otherwise false. - */ - function str_ends_with( $haystack, $needle ) { - if ( '' === $haystack ) { - return '' === $needle; - } - - $len = strlen( $needle ); - - return substr( $haystack, -$len, $len ) === $needle; - } + return 0 === strpos( $haystack, $needle ); + } +} + +if ( ! function_exists( 'str_ends_with' ) ) { + /** + * Polyfill for `str_ends_with()` function added in PHP 8.0. + * + * Performs a case-sensitive check indicating if + * the haystack ends with needle. + * + * @since 5.9.0 + * + * @param string $haystack The string to search in. + * @param string $needle The substring to search for in the `$haystack`. + * @return bool True if `$haystack` ends with `$needle`, otherwise false. + */ + function str_ends_with( $haystack, $needle ) { + if ( '' === $haystack ) { + return '' === $needle; + } + + $len = strlen( $needle ); + + return substr( $haystack, -$len, $len ) === $needle; } }