Revert "Make compatible with PHP<8"

This reverts commit bb967b3dd3.
This commit is contained in:
Fabien Potencier
2024-07-14 12:17:49 +02:00
parent 4afc66cc82
commit 21cd159ff2
2 changed files with 6 additions and 10 deletions
+2 -6
View File
@@ -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'));
}
}
+4 -4
View File
@@ -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;
}