Changeset 57337 for trunk/src/wp-includes/compat.php
- Timestamp:
- 01/23/2024 01:32:34 PM (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/compat.php
r56549 r57337 421 421 } 422 422 423 if ( ! function_exists( 'array_is_list' ) ) { 424 /** 425 * Polyfill for `array_is_list()` function added in PHP 8.1. 426 * 427 * Determines if the given array is a list. 428 * 429 * An array is considered a list if its keys consist of consecutive numbers from 0 to count($array)-1. 430 * 431 * @see https://github.com/symfony/polyfill-php81/tree/main 432 * 433 * @since 6.5.0 434 * 435 * @param array<mixed> $arr The array being evaluated. 436 * @return bool True if array is a list, false otherwise. 437 */ 438 function array_is_list( $arr ) { 439 if ( ( array() === $arr ) || ( array_values( $arr ) === $arr ) ) { 440 return true; 441 } 442 443 $next_key = -1; 444 445 foreach ( $arr as $k => $v ) { 446 if ( ++$next_key !== $k ) { 447 return false; 448 } 449 } 450 451 return true; 452 } 453 } 454 423 455 if ( ! function_exists( 'str_contains' ) ) { 424 456 /**
Note: See TracChangeset
for help on using the changeset viewer.