diff --git a/ExpressionFunction.php b/ExpressionFunction.php index d0ddd10..0b3d6c4 100644 --- a/ExpressionFunction.php +++ b/ExpressionFunction.php @@ -70,7 +70,7 @@ public function getEvaluator(): \Closure * @throws \InvalidArgumentException if given PHP function name is in namespace * and expression function name is not defined */ - public static function fromPhp(string $phpFunctionName, string $expressionFunctionName = null): self + public static function fromPhp(string $phpFunctionName, ?string $expressionFunctionName = null): self { $phpFunctionName = ltrim($phpFunctionName, '\\'); if (!\function_exists($phpFunctionName)) { diff --git a/ExpressionLanguage.php b/ExpressionLanguage.php index 9e10740..a7f249f 100644 --- a/ExpressionLanguage.php +++ b/ExpressionLanguage.php @@ -34,7 +34,7 @@ class ExpressionLanguage /** * @param ExpressionFunctionProviderInterface[] $providers */ - public function __construct(CacheItemPoolInterface $cache = null, array $providers = []) + public function __construct(?CacheItemPoolInterface $cache = null, array $providers = []) { $this->cache = $cache ?? new ArrayAdapter(); $this->registerFunctions(); diff --git a/Node/ArrayNode.php b/Node/ArrayNode.php index 993af36..79eade2 100644 --- a/Node/ArrayNode.php +++ b/Node/ArrayNode.php @@ -27,7 +27,7 @@ public function __construct() $this->index = -1; } - public function addElement(Node $value, Node $key = null): void + public function addElement(Node $value, ?Node $key = null): void { $key ??= new ConstantNode(++$this->index); diff --git a/SyntaxError.php b/SyntaxError.php index 0bfd7e9..e165dc2 100644 --- a/SyntaxError.php +++ b/SyntaxError.php @@ -13,7 +13,7 @@ class SyntaxError extends \LogicException { - public function __construct(string $message, int $cursor = 0, string $expression = '', string $subject = null, array $proposals = null) + public function __construct(string $message, int $cursor = 0, string $expression = '', ?string $subject = null, ?array $proposals = null) { $message = sprintf('%s around position %d', rtrim($message, '.'), $cursor); if ($expression) { diff --git a/Tests/ExpressionLanguageTest.php b/Tests/ExpressionLanguageTest.php index 167f784..93dbeb6 100644 --- a/Tests/ExpressionLanguageTest.php +++ b/Tests/ExpressionLanguageTest.php @@ -366,7 +366,7 @@ public function testNullSafeCompileFails($expression, $foo) $this->expectException(\ErrorException::class); - set_error_handler(static function (int $errno, string $errstr, string $errfile = null, int $errline = null): bool { + set_error_handler(static function (int $errno, string $errstr, ?string $errfile = null, ?int $errline = null): bool { if ($errno & (\E_WARNING | \E_USER_WARNING) && (str_contains($errstr, 'Attempt to read property') || str_contains($errstr, 'Trying to access'))) { throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); } diff --git a/Tests/ParserTest.php b/Tests/ParserTest.php index 58a232e..9c546e3 100644 --- a/Tests/ParserTest.php +++ b/Tests/ParserTest.php @@ -284,7 +284,7 @@ public function testNameProposal() /** * @dataProvider getLintData */ - public function testLint($expression, $names, string $exception = null) + public function testLint($expression, $names, ?string $exception = null) { if ($exception) { $this->expectException(SyntaxError::class); diff --git a/Token.php b/Token.php index 6eff31e..99f721f 100644 --- a/Token.php +++ b/Token.php @@ -51,7 +51,7 @@ public function __toString(): string /** * Tests the current token for a type and/or a value. */ - public function test(string $type, string $value = null): bool + public function test(string $type, ?string $value = null): bool { return $this->type === $type && (null === $value || $this->value == $value); } diff --git a/TokenStream.php b/TokenStream.php index 241725b..9512a10 100644 --- a/TokenStream.php +++ b/TokenStream.php @@ -60,7 +60,7 @@ public function next() * * @return void */ - public function expect(string $type, string $value = null, string $message = null) + public function expect(string $type, ?string $value = null, ?string $message = null) { $token = $this->current; if (!$token->test($type, $value)) {