提交的内容

This commit is contained in:
2025-05-12 15:45:02 +08:00
parent 629c4750da
commit b48c692775
3043 changed files with 34732 additions and 60810 deletions

10
vendor/mtdowling/jmespath.php/CHANGELOG.md vendored Executable file → Normal file
View File

@ -1,5 +1,15 @@
# CHANGELOG
## 2.8.0 - 2024-09-04
* Add support for PHP 8.4.
## 2.7.0 - 2023-08-15
* Fixed flattening in arrays starting with null.
* Drop support for HHVM and PHP earlier than 7.2.5.
* Add support for PHP 8.1, 8.2, and 8.3.
## 2.6.0 - 2020-07-31
* Support for PHP 8.0.

0
vendor/mtdowling/jmespath.php/LICENSE vendored Executable file → Normal file
View File

2
vendor/mtdowling/jmespath.php/README.rst vendored Executable file → Normal file
View File

@ -4,7 +4,7 @@ jmespath.php
JMESPath (pronounced "jaymz path") allows you to declaratively specify how to
extract elements from a JSON document. *jmespath.php* allows you to use
JMESPath in PHP applications with PHP data structures. It requires PHP 5.4 or
JMESPath in PHP applications with PHP data structures. It requires PHP 7.2.5 or
greater and can be installed through `Composer <http://getcomposer.org/doc/00-intro.md>`_
using the ``mtdowling/jmespath.php`` package.

74
vendor/mtdowling/jmespath.php/bin/jp.php vendored Executable file
View File

@ -0,0 +1,74 @@
#!/usr/bin/env php
<?php
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
require __DIR__ . '/../vendor/autoload.php';
} elseif (file_exists(__DIR__ . '/../../../autoload.php')) {
require __DIR__ . '/../../../autoload.php';
} elseif (file_exists(__DIR__ . '/../autoload.php')) {
require __DIR__ . '/../autoload.php';
} else {
throw new RuntimeException('Unable to locate autoload.php file.');
}
use JmesPath\Env;
use JmesPath\DebugRuntime;
$description = <<<EOT
Runs a JMESPath expression on the provided input or a test case.
Provide the JSON input and expression:
echo '{}' | jp.php expression
Or provide the path to a compliance script, a suite, and test case number:
jp.php --script path_to_script --suite test_suite_number --case test_case_number [expression]
EOT;
$args = [];
$currentKey = null;
for ($i = 1, $total = count($argv); $i < $total; $i++) {
if ($i % 2) {
if (substr($argv[$i], 0, 2) == '--') {
$currentKey = str_replace('--', '', $argv[$i]);
} else {
$currentKey = trim($argv[$i]);
}
} else {
$args[$currentKey] = $argv[$i];
$currentKey = null;
}
}
$expression = $currentKey;
if (isset($args['file']) || isset($args['suite']) || isset($args['case'])) {
if (!isset($args['file']) || !isset($args['suite']) || !isset($args['case'])) {
die($description);
}
// Manually run a compliance test
$path = realpath($args['file']);
file_exists($path) or die('File not found at ' . $path);
$json = json_decode(file_get_contents($path), true);
$set = $json[$args['suite']];
$data = $set['given'];
if (!isset($expression)) {
$expression = $set['cases'][$args['case']]['expression'];
echo "Expects\n=======\n";
if (isset($set['cases'][$args['case']]['result'])) {
echo json_encode($set['cases'][$args['case']]['result'], JSON_PRETTY_PRINT) . "\n\n";
} elseif (isset($set['cases'][$args['case']]['error'])) {
echo "{$set['cases'][$argv['case']]['error']} error\n\n";
} else {
echo "NULL\n\n";
}
}
} elseif (isset($expression)) {
// Pass in an expression and STDIN as a standalone argument
$data = json_decode(stream_get_contents(STDIN), true);
} else {
die($description);
}
$runtime = new DebugRuntime(Env::createRuntime());
$runtime($expression, $data);

68
vendor/mtdowling/jmespath.php/bin/perf.php vendored Executable file
View File

@ -0,0 +1,68 @@
#!/usr/bin/env php
<?php
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
require __DIR__ . '/../vendor/autoload.php';
} elseif (file_exists(__DIR__ . '/../../../autoload.php')) {
require __DIR__ . '/../../../autoload.php';
} else {
throw new RuntimeException('Unable to locate autoload.php file.');
}
$xdebug = new \Composer\XdebugHandler\XdebugHandler('perf.php');
$xdebug->check();
unset($xdebug);
$dir = isset($argv[1]) ? $argv[1] : __DIR__ . '/../tests/compliance/perf';
is_dir($dir) or die('Dir not found: ' . $dir);
// Warm up the runner
\JmesPath\Env::search('foo', []);
$total = 0;
foreach (glob($dir . '/*.json') as $file) {
$total += runSuite($file);
}
echo "\nTotal time: {$total}\n";
function runSuite($file)
{
$contents = file_get_contents($file);
$json = json_decode($contents, true);
$total = 0;
foreach ($json as $suite) {
foreach ($suite['cases'] as $case) {
$total += runCase(
$suite['given'],
$case['expression'],
$case['name']
);
}
}
return $total;
}
function runCase($given, $expression, $name)
{
$best = 99999;
$runtime = \JmesPath\Env::createRuntime();
for ($i = 0; $i < 100; $i++) {
$t = microtime(true);
$runtime($expression, $given);
$tryTime = (microtime(true) - $t) * 1000;
if ($tryTime < $best) {
$best = $tryTime;
}
if (!getenv('CACHE')) {
$runtime = \JmesPath\Env::createRuntime();
// Delete compiled scripts if not caching.
if ($runtime instanceof \JmesPath\CompilerRuntime) {
array_map('unlink', glob(sys_get_temp_dir() . '/jmespath_*.php'));
}
}
}
printf("time: %07.4fms name: %s\n", $best, $name);
return $best;
}

69
vendor/mtdowling/jmespath.php/composer.json vendored Executable file → Normal file
View File

@ -1,39 +1,38 @@
{
"name": "mtdowling/jmespath.php",
"description": "Declaratively specify how to extract elements from a JSON document",
"keywords": ["json", "jsonpath"],
"license": "MIT",
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"require": {
"php": "^5.4 || ^7.0 || ^8.0",
"symfony/polyfill-mbstring": "^1.17"
},
"require-dev": {
"composer/xdebug-handler": "^1.4 || ^2.0",
"phpunit/phpunit": "^4.8.36 || ^7.5.15"
},
"autoload": {
"psr-4": {
"JmesPath\\": "src/"
"name": "mtdowling/jmespath.php",
"description": "Declaratively specify how to extract elements from a JSON document",
"keywords": ["json", "jsonpath"],
"license": "MIT",
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"require": {
"php": "^7.2.5 || ^8.0",
"symfony/polyfill-mbstring": "^1.17"
},
"files": ["src/JmesPath.php"]
},
"bin": ["bin/jp.php"],
"extra": {
"branch-alias": {
"dev-master": "2.6-dev"
"require-dev": {
"composer/xdebug-handler": "^3.0.3",
"phpunit/phpunit": "^8.5.33"
},
"autoload": {
"psr-4": {
"JmesPath\\": "src/"
},
"files": ["src/JmesPath.php"]
},
"bin": ["bin/jp.php"],
"extra": {
"branch-alias": {
"dev-master": "2.8-dev"
}
}
}
}

4
vendor/mtdowling/jmespath.php/src/AstRuntime.php vendored Executable file → Normal file
View File

@ -12,8 +12,8 @@ class AstRuntime
private $cachedCount = 0;
public function __construct(
Parser $parser = null,
callable $fnDispatcher = null
?Parser $parser = null,
?callable $fnDispatcher = null
) {
$fnDispatcher = $fnDispatcher ?: FnDispatcher::getInstance();
$this->interpreter = new TreeInterpreter($fnDispatcher);

2
vendor/mtdowling/jmespath.php/src/CompilerRuntime.php vendored Executable file → Normal file
View File

@ -23,7 +23,7 @@ class CompilerRuntime
* @param Parser|null $parser JMESPath parser to utilize
* @throws \RuntimeException if the cache directory cannot be created
*/
public function __construct($dir = null, Parser $parser = null)
public function __construct($dir = null, ?Parser $parser = null)
{
$this->parser = $parser ?: new Parser();
$this->compiler = new TreeCompiler();

0
vendor/mtdowling/jmespath.php/src/DebugRuntime.php vendored Executable file → Normal file
View File

0
vendor/mtdowling/jmespath.php/src/Env.php vendored Executable file → Normal file
View File

0
vendor/mtdowling/jmespath.php/src/FnDispatcher.php vendored Executable file → Normal file
View File

0
vendor/mtdowling/jmespath.php/src/JmesPath.php vendored Executable file → Normal file
View File

0
vendor/mtdowling/jmespath.php/src/Lexer.php vendored Executable file → Normal file
View File

8
vendor/mtdowling/jmespath.php/src/Parser.php vendored Executable file → Normal file
View File

@ -57,7 +57,7 @@ class Parser
/**
* @param Lexer|null $lexer Lexer used to tokenize expressions
*/
public function __construct(Lexer $lexer = null)
public function __construct(?Lexer $lexer = null)
{
$this->lexer = $lexer ?: new Lexer();
}
@ -366,7 +366,7 @@ class Parser
];
}
private function parseWildcardObject(array $left = null)
private function parseWildcardObject(?array $left = null)
{
$this->next();
@ -380,7 +380,7 @@ class Parser
];
}
private function parseWildcardArray(array $left = null)
private function parseWildcardArray(?array $left = null)
{
static $getRbracket = [T::T_RBRACKET => true];
$this->next($getRbracket);
@ -473,7 +473,7 @@ class Parser
: $this->tokens[$this->tpos + 1]['type'];
}
private function next(array $match = null)
private function next(?array $match = null)
{
if (!isset($this->tokens[$this->tpos + 1])) {
$this->token = self::$nullToken;

2
vendor/mtdowling/jmespath.php/src/SyntaxErrorException.php vendored Executable file → Normal file
View File

@ -16,7 +16,7 @@ class SyntaxErrorException extends \InvalidArgumentException
array $token,
$expression
) {
$message = "Syntax error at character {$token['pos']}\n"
$message = sprintf("Syntax error at character %d\n", max($token['pos'], 0))
. $expression . "\n" . str_repeat(' ', max($token['pos'], 0)) . "^\n";
$message .= !is_array($expectedTypesOrMessage)
? $expectedTypesOrMessage

2
vendor/mtdowling/jmespath.php/src/TreeCompiler.php vendored Executable file → Normal file
View File

@ -305,7 +305,7 @@ class TreeCompiler
->write('%s = [];', $merged)
->write('foreach ($value as %s) {', $val)
->indent()
->write('if (is_array(%s) && isset(%s[0])) {', $val, $val)
->write('if (is_array(%s) && array_key_exists(0, %s)) {', $val, $val)
->indent()
->write('%s = array_merge(%s, %s);', $merged, $merged, $val)
->outdent()

4
vendor/mtdowling/jmespath.php/src/TreeInterpreter.php vendored Executable file → Normal file
View File

@ -14,7 +14,7 @@ class TreeInterpreter
* a function name argument and an array of
* function arguments and returns the result.
*/
public function __construct(callable $fnDispatcher = null)
public function __construct(?callable $fnDispatcher = null)
{
$this->fnDispatcher = $fnDispatcher ?: FnDispatcher::getInstance();
}
@ -107,7 +107,7 @@ class TreeInterpreter
$merged = [];
foreach ($value as $values) {
// Only merge up arrays lists and not hashes
if (is_array($values) && isset($values[0])) {
if (is_array($values) && array_key_exists(0, $values)) {
$merged = array_merge($merged, $values);
} elseif ($values !== $skipElement) {
$merged[] = $values;

0
vendor/mtdowling/jmespath.php/src/Utils.php vendored Executable file → Normal file
View File