From 21cd159ff29220bb2db5b9f95cee99da666784b3 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 14 Jul 2024 12:17:49 +0200 Subject: [PATCH] Revert "Make compatible with PHP<8" This reverts commit bb967b3dd372fbd93629133758b30c4342442e58. --- src/Node/Expression/CallExpression.php | 8 ++------ src/Util/ReflectionCallable.php | 8 ++++---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Node/Expression/CallExpression.php b/src/Node/Expression/CallExpression.php index f63a4b83b..2b64b246c 100644 --- a/src/Node/Expression/CallExpression.php +++ b/src/Node/Expression/CallExpression.php @@ -19,7 +19,7 @@ use Twig\Util\ReflectionCallable; abstract class CallExpression extends AbstractExpression { - private $reflector = null; + private ?ReflectionCallable $reflector = null; protected function compileCallable(Compiler $compiler) { @@ -291,10 +291,6 @@ abstract class CallExpression extends AbstractExpression private function reflectCallable($callable): ReflectionCallable { - if (!$this->reflector) { - $this->reflector = new ReflectionCallable($callable, $this->getAttribute('type'), $this->getAttribute('name')); - } - - return $this->reflector; + return $this->reflector ??= new ReflectionCallable($callable, $this->getAttribute('type'), $this->getAttribute('name')); } } diff --git a/src/Util/ReflectionCallable.php b/src/Util/ReflectionCallable.php index f82d5a18e..ade284d63 100644 --- a/src/Util/ReflectionCallable.php +++ b/src/Util/ReflectionCallable.php @@ -18,9 +18,9 @@ namespace Twig\Util; */ final class ReflectionCallable { - private $reflector; - private $callable = null; - private $name; + private \ReflectionFunctionAbstract $reflector; + private \Closure|string|array|null $callable = null; + private string $name; public function __construct($callable, string $debugType = 'unknown', string $debugName = 'unknown') { @@ -72,7 +72,7 @@ final class ReflectionCallable return $this->reflector; } - public function getCallable() + public function getCallable(): \Closure|string|array|null { return $this->callable; }