mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 03:46:39 +00:00
Make compatible with PHP<8
This commit is contained in:
@@ -19,7 +19,7 @@ use Twig\Util\ReflectionCallable;
|
|||||||
|
|
||||||
abstract class CallExpression extends AbstractExpression
|
abstract class CallExpression extends AbstractExpression
|
||||||
{
|
{
|
||||||
private ?ReflectionCallable $reflector = null;
|
private $reflector = null;
|
||||||
|
|
||||||
protected function compileCallable(Compiler $compiler)
|
protected function compileCallable(Compiler $compiler)
|
||||||
{
|
{
|
||||||
@@ -295,6 +295,10 @@ abstract class CallExpression extends AbstractExpression
|
|||||||
|
|
||||||
private function reflectCallable($callable): ReflectionCallable
|
private function reflectCallable($callable): ReflectionCallable
|
||||||
{
|
{
|
||||||
return $this->reflector ??= new ReflectionCallable($callable, $this->getAttribute('type'), $this->getAttribute('name'));
|
if (!$this->reflector) {
|
||||||
|
$this->reflector = new ReflectionCallable($callable, $this->getAttribute('type'), $this->getAttribute('name'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->reflector;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ namespace Twig\Util;
|
|||||||
*/
|
*/
|
||||||
final class ReflectionCallable
|
final class ReflectionCallable
|
||||||
{
|
{
|
||||||
private \ReflectionFunctionAbstract $reflector;
|
private $reflector;
|
||||||
private \Closure|string|array|null $callable = null;
|
private $callable = null;
|
||||||
private string $name;
|
private $name;
|
||||||
|
|
||||||
public function __construct($callable, string $debugType = 'unknown', string $debugName = 'unknown')
|
public function __construct($callable, string $debugType = 'unknown', string $debugName = 'unknown')
|
||||||
{
|
{
|
||||||
@@ -74,7 +74,7 @@ final class ReflectionCallable
|
|||||||
return $this->reflector;
|
return $this->reflector;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCallable(): \Closure|string|array|null
|
public function getCallable()
|
||||||
{
|
{
|
||||||
return $this->callable;
|
return $this->callable;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user