forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
71 changed files
with
2,811 additions
and
549 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* WordPress 6.5 compatibility functions. | ||
* | ||
* @package WordPress | ||
*/ | ||
|
||
if ( ! function_exists( 'array_is_list' ) ) { | ||
/** | ||
* Polyfill for `array_is_list()` function added in PHP 8.1. | ||
* | ||
* Determines if the given array is a list. | ||
* | ||
* An array is considered a list if its keys consist of consecutive numbers from 0 to count($array)-1. | ||
* | ||
* @see https://github.com/symfony/polyfill-php81/tree/main | ||
* | ||
* @since 6.5.0 | ||
* | ||
* @param array<mixed> $arr The array being evaluated. | ||
* @return bool True if array is a list, false otherwise. | ||
*/ | ||
function array_is_list( $arr ) { | ||
if ( ( array() === $arr ) || ( array_values( $arr ) === $arr ) ) { | ||
return true; | ||
} | ||
|
||
$next_key = -1; | ||
|
||
foreach ( $arr as $k => $v ) { | ||
if ( ++$next_key !== $k ) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.