From 6c835a9be7839d80381d48d1ad0fd687321daf24 Mon Sep 17 00:00:00 2001 From: Julius Kiekbusch Date: Wed, 4 Sep 2024 20:23:43 +0200 Subject: [PATCH] Mark parameters explicit nullable --- src/AstRuntime.php | 4 ++-- src/CompilerRuntime.php | 2 +- src/Parser.php | 8 ++++---- src/TreeInterpreter.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) 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(); }