$v) { if ($k !== ++$next_key) { return FALSE; } } return TRUE; } } // PHP (8.3) compat functions if (PHP_VERSION_ID < 80300) { function json_validate(string $json, int $depth = 512, int $flags = 0) { if (0 !== $flags && defined('JSON_INVALID_UTF8_IGNORE') && JSON_INVALID_UTF8_IGNORE !== $flags) { throw new \ValueError('json_validate(): Argument #3 ($flags) must be a valid flag (allowed flags: JSON_INVALID_UTF8_IGNORE)'); } if ($depth <= 0) { throw new \ValueError('json_validate(): Argument #2 ($depth) must be greater than 0'); } // see https://www.php.net/manual/en/function.json-decode.php if ($depth > 2147483647) { throw new \ValueError(sprintf('json_validate(): Argument #2 ($depth) must be less than %d', 2147483647)); } json_decode($json, NULL, $depth, $flags); return JSON_ERROR_NONE === json_last_error(); } } // PHP (8.4) compat functions if (PHP_VERSION_ID < 80400) { function array_find(array $array, callable $callback) { foreach ($array as $key => $value) { if ($callback($value, $key)) { return $value; } } return NULL; } function array_find_key(array $array, callable $callback) { foreach ($array as $key => $value) { if ($callback($value, $key)) { return $key; } } return NULL; } function array_any(array $array, callable $callback) { foreach ($array as $key => $value) { if ($callback($value, $key)) { return TRUE; } } return FALSE; } function array_all(array $array, callable $callback) { foreach ($array as $key => $value) { if (!$callback($value, $key)) { return FALSE; } } return TRUE; } } // EOF