| @@ -41,10 +41,22 @@ | ||
| 41 | 41 | return strlen( $needle ) === 0 || substr( $haystack, - strlen( $needle ) ) === $needle; |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | +if ( ! function_exists( 'is_countable' ) ) { | |
| 46 | + /** | |
| 47 | + * Polyfill for `is_countable()` function added in PHP 7.3. | |
| 48 | + * | |
| 49 | + * @param mixed $value The value to check. | |
| 50 | + * @return bool True if `$value` is countable, otherwise false. | |
| 51 | + */ | |
| 52 | + function is_countable( $value ) { | |
| 53 | + return is_array( $value ) || $value instanceof Countable; | |
| 54 | + } | |
| 55 | +} | |
| 56 | + | |
| 45 | 57 | /** |
| 46 | - * Polyfill for `array_is_list()` function added in PHP 8.1. | |
| 58 | + * Polyfill for `array_is_list()` function added in PHP 7.3. | |
| 47 | 59 | * |
| 48 | 60 | * @param array $array The array to check. |
| 49 | 61 | * |
| 50 | 62 | * @return bool True if `$array` is a list, otherwise false. |