From d658c37a6eecfa2caaa8428ab8f88d6731d92fef Mon Sep 17 00:00:00 2001 From: Julius Kiekbusch Date: Wed, 4 Sep 2024 20:45:02 +0200 Subject: [PATCH] PHP 8.4 support (#84) * Mark parameters explicit nullable * Test on PHP 8.4 * Update composer.json * Update CHANGELOG.md --------- Co-authored-by: Graham Campbell --- .github/workflows/tests.yml | 4 ++-- CHANGELOG.md | 6 +++++- composer.json | 2 +- src/AstRuntime.php | 4 ++-- src/CompilerRuntime.php | 2 +- src/Parser.php | 8 ++++---- src/TreeInterpreter.php | 2 +- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8dce692..2b6b441 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: - php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] steps: - name: Checkout Code @@ -43,7 +43,7 @@ jobs: strategy: matrix: - php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] steps: - name: Configure Git diff --git a/CHANGELOG.md b/CHANGELOG.md index b3a4048..8acb57c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,12 @@ # CHANGELOG +## 2.8.0 - UPCOMING + +* Add support for PHP 8.4. + ## 2.7.0 - 2023-08-15 -* Fixed flattening in arrays starting with null +* 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. diff --git a/composer.json b/composer.json index b4c37c1..819db12 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "bin": ["bin/jp.php"], "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "2.8-dev" } } } diff --git a/src/AstRuntime.php b/src/AstRuntime.php index 03f5f1a..f5620be 100644 --- a/src/AstRuntime.php +++ b/src/AstRuntime.php @@ -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); diff --git a/src/CompilerRuntime.php b/src/CompilerRuntime.php index c26b09c..b85f68e 100644 --- a/src/CompilerRuntime.php +++ b/src/CompilerRuntime.php @@ -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(); diff --git a/src/Parser.php b/src/Parser.php index 0733f20..d126de5 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -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 @@ private function parseKeyValuePair() ]; } - private function parseWildcardObject(array $left = null) + private function parseWildcardObject(?array $left = null) { $this->next(); @@ -380,7 +380,7 @@ private function parseWildcardObject(array $left = null) ]; } - 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 @@ private function lookahead() : $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; diff --git a/src/TreeInterpreter.php b/src/TreeInterpreter.php index f7eea86..f4a8aec 100644 --- a/src/TreeInterpreter.php +++ b/src/TreeInterpreter.php @@ -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(); }