Changeset 61459 for trunk/src/wp-includes/compat.php
- Timestamp:
- 01/09/2026 11:45:46 AM (2 months ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/compat.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/compat.php
r61328 r61459 297 297 endif; 298 298 299 // sodium_crypto_box() was introduced in PHP 7.2.299 // sodium_crypto_box() was introduced with Sodium in PHP 7.2, but the extension may not be enabled. 300 300 if ( ! function_exists( 'sodium_crypto_box' ) ) { 301 301 require ABSPATH . WPINC . '/sodium_compat/autoload.php'; 302 }303 304 if ( ! function_exists( 'is_countable' ) ) {305 /**306 * Polyfill for is_countable() function added in PHP 7.3.307 *308 * Verify that the content of a variable is an array or an object309 * implementing the Countable interface.310 *311 * @since 4.9.6312 *313 * @param mixed $value The value to check.314 * @return bool True if `$value` is countable, false otherwise.315 */316 function is_countable( $value ) {317 return ( is_array( $value )318 || $value instanceof Countable319 || $value instanceof SimpleXMLElement320 || $value instanceof ResourceBundle321 );322 }323 }324 325 if ( ! function_exists( 'array_key_first' ) ) {326 /**327 * Polyfill for array_key_first() function added in PHP 7.3.328 *329 * Get the first key of the given array without affecting330 * the internal array pointer.331 *332 * @since 5.9.0333 *334 * @param array $array An array.335 * @return string|int|null The first key of array if the array336 * is not empty; `null` otherwise.337 */338 function array_key_first( array $array ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.arrayFound339 if ( empty( $array ) ) {340 return null;341 }342 343 foreach ( $array as $key => $value ) {344 return $key;345 }346 }347 }348 349 if ( ! function_exists( 'array_key_last' ) ) {350 /**351 * Polyfill for `array_key_last()` function added in PHP 7.3.352 *353 * Get the last key of the given array without affecting the354 * internal array pointer.355 *356 * @since 5.9.0357 *358 * @param array $array An array.359 * @return string|int|null The last key of array if the array360 *. is not empty; `null` otherwise.361 */362 function array_key_last( array $array ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.arrayFound363 if ( empty( $array ) ) {364 return null;365 }366 367 end( $array );368 369 return key( $array );370 }371 302 } 372 303
Note: See TracChangeset
for help on using the changeset viewer.