diff --git a/src/ExpressionParser.php b/src/ExpressionParser.php index 3cb174de0..e7ba93805 100644 --- a/src/ExpressionParser.php +++ b/src/ExpressionParser.php @@ -92,7 +92,7 @@ class ExpressionParser public function parseExpression($precedence = 0) { - if (func_num_args() > 1) { + if (\func_num_args() > 1) { trigger_deprecation('twig/twig', '3.15', 'Passing a second argument ($allowArrow) to "%s()" is deprecated.', __METHOD__); } @@ -153,7 +153,7 @@ class ExpressionParser /** @var AbstractExpression $node */ $node = $expr->getNode('node'); foreach ($this->precedenceChanges as $operatorName => $changes) { - if (!in_array($unaryOp, $changes)) { + if (!\in_array($unaryOp, $changes)) { continue; } if ($node->hasAttribute('operator') && $operatorName === $node->getAttribute('operator')) { @@ -616,10 +616,10 @@ class ExpressionParser { $namedArguments = false; $definition = false; - if (func_num_args() > 1) { + if (\func_num_args() > 1) { $definition = func_get_arg(1); } - if (func_num_args() > 0) { + if (\func_num_args() > 0) { trigger_deprecation('twig/twig', '3.15', 'Passing arguments to "%s()" is deprecated.', __METHOD__); $namedArguments = func_get_arg(0); } diff --git a/src/Extension/CoreExtension.php b/src/Extension/CoreExtension.php index cb54adc75..eb890b787 100644 --- a/src/Extension/CoreExtension.php +++ b/src/Extension/CoreExtension.php @@ -1543,11 +1543,11 @@ final class CoreExtension extends AbstractExtension public static function enum(string $enum): \UnitEnum { if (!enum_exists($enum)) { - throw new RuntimeError(sprintf('"%s" is not an enum.', $enum)); + throw new RuntimeError(\sprintf('"%s" is not an enum.', $enum)); } if (!$cases = $enum::cases()) { - throw new RuntimeError(sprintf('"%s" is an empty enum.', $enum)); + throw new RuntimeError(\sprintf('"%s" is an empty enum.', $enum)); } return $cases[0]; diff --git a/src/Node/Expression/Binary/AbstractBinary.php b/src/Node/Expression/Binary/AbstractBinary.php index ccd3be44f..09530273a 100644 --- a/src/Node/Expression/Binary/AbstractBinary.php +++ b/src/Node/Expression/Binary/AbstractBinary.php @@ -25,10 +25,10 @@ abstract class AbstractBinary extends AbstractExpression public function __construct(Node $left, Node $right, int $lineno) { if (!$left instanceof AbstractExpression) { - trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "left" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, get_class($left)); + trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "left" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($left)); } if (!$right instanceof AbstractExpression) { - trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "right" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, get_class($right)); + trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "right" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($right)); } parent::__construct(['left' => $left, 'right' => $right], [], $lineno); diff --git a/src/Node/Expression/BlockReferenceExpression.php b/src/Node/Expression/BlockReferenceExpression.php index 0094c7adb..a5a3cee3f 100644 --- a/src/Node/Expression/BlockReferenceExpression.php +++ b/src/Node/Expression/BlockReferenceExpression.php @@ -28,7 +28,7 @@ class BlockReferenceExpression extends AbstractExpression public function __construct(Node $name, ?Node $template, int $lineno) { if (!$name instanceof AbstractExpression) { - trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, get_class($name)); + trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($name)); } $nodes = ['name' => $name]; diff --git a/src/Node/Expression/Filter/DefaultFilter.php b/src/Node/Expression/Filter/DefaultFilter.php index 60ebc6b83..cabd2aa1a 100644 --- a/src/Node/Expression/Filter/DefaultFilter.php +++ b/src/Node/Expression/Filter/DefaultFilter.php @@ -42,7 +42,7 @@ class DefaultFilter extends FilterExpression public function __construct(Node $node, TwigFilter|ConstantExpression $filter, Node $arguments, int $lineno) { if (!$node instanceof AbstractExpression) { - trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, get_class($node)); + trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($node)); } if ($filter instanceof TwigFilter) { diff --git a/src/Node/Expression/Filter/RawFilter.php b/src/Node/Expression/Filter/RawFilter.php index e70501e24..0a49e7c4f 100644 --- a/src/Node/Expression/Filter/RawFilter.php +++ b/src/Node/Expression/Filter/RawFilter.php @@ -32,7 +32,7 @@ class RawFilter extends FilterExpression public function __construct(Node $node, TwigFilter|ConstantExpression|null $filter = null, ?Node $arguments = null, int $lineno = 0) { if (!$node instanceof AbstractExpression) { - trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, get_class($node)); + trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($node)); } parent::__construct($node, $filter ?: new TwigFilter('raw', null, ['is_safe' => ['all']]), $arguments ?: new EmptyNode(), $lineno ?: $node->getTemplateLine()); diff --git a/src/Node/Expression/FilterExpression.php b/src/Node/Expression/FilterExpression.php index 31fb90f1e..6e0c486ab 100644 --- a/src/Node/Expression/FilterExpression.php +++ b/src/Node/Expression/FilterExpression.php @@ -27,7 +27,7 @@ class FilterExpression extends CallExpression public function __construct(Node $node, TwigFilter|ConstantExpression $filter, Node $arguments, int $lineno) { if (!$node instanceof AbstractExpression) { - trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, get_class($node)); + trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($node)); } if ($filter instanceof TwigFilter) { diff --git a/src/Node/Expression/NullCoalesceExpression.php b/src/Node/Expression/NullCoalesceExpression.php index 5c9a27689..be2136ca5 100644 --- a/src/Node/Expression/NullCoalesceExpression.php +++ b/src/Node/Expression/NullCoalesceExpression.php @@ -32,10 +32,10 @@ class NullCoalesceExpression extends ConditionalExpression trigger_deprecation('twig/twig', '3.16', \sprintf('"%s" is deprecated; use "%s" instead.', __CLASS__, NullCoalesceBinary::class)); if (!$left instanceof AbstractExpression) { - trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "left" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, get_class($left)); + trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "left" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($left)); } if (!$right instanceof AbstractExpression) { - trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "right" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, get_class($right)); + trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "right" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($right)); } $test = new DefinedTest(clone $left, new TwigTest('defined'), new EmptyNode(), $left->getTemplateLine()); diff --git a/src/Node/Expression/TempNameExpression.php b/src/Node/Expression/TempNameExpression.php index 925b0e7b3..8cb66a193 100644 --- a/src/Node/Expression/TempNameExpression.php +++ b/src/Node/Expression/TempNameExpression.php @@ -29,9 +29,9 @@ class TempNameExpression extends AbstractExpression trigger_deprecation('twig/twig', '3.15', 'The "%s" class is deprecated.', self::class); } - if (null !== $name && (is_int($name) || ctype_digit($name))) { + if (null !== $name && (\is_int($name) || ctype_digit($name))) { $name = (int) $name; - } elseif (in_array($name, self::RESERVED_NAMES)) { + } elseif (\in_array($name, self::RESERVED_NAMES)) { $name = "\u{035C}".$name; } diff --git a/src/Node/Expression/Test/DefinedTest.php b/src/Node/Expression/Test/DefinedTest.php index b6c3ff6f9..7a0150d18 100644 --- a/src/Node/Expression/Test/DefinedTest.php +++ b/src/Node/Expression/Test/DefinedTest.php @@ -46,7 +46,7 @@ class DefinedTest extends TestExpression public function __construct(Node $node, TwigTest|string $name, ?Node $arguments, int $lineno) { if (!$node instanceof AbstractExpression) { - trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, get_class($node)); + trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($node)); } if ($node instanceof NameExpression) { diff --git a/src/Node/Expression/TestExpression.php b/src/Node/Expression/TestExpression.php index 3ad6ac557..7b9a54138 100644 --- a/src/Node/Expression/TestExpression.php +++ b/src/Node/Expression/TestExpression.php @@ -26,7 +26,7 @@ class TestExpression extends CallExpression public function __construct(Node $node, string|TwigTest $test, ?Node $arguments, int $lineno) { if (!$node instanceof AbstractExpression) { - trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, get_class($node)); + trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($node)); } $nodes = ['node' => $node]; diff --git a/src/Node/Expression/Unary/AbstractUnary.php b/src/Node/Expression/Unary/AbstractUnary.php index 96739e2b8..d4746e73b 100644 --- a/src/Node/Expression/Unary/AbstractUnary.php +++ b/src/Node/Expression/Unary/AbstractUnary.php @@ -24,7 +24,7 @@ abstract class AbstractUnary extends AbstractExpression public function __construct(Node $node, int $lineno) { if (!$node instanceof AbstractExpression) { - trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance argument to "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, get_class($node)); + trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance argument to "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($node)); } parent::__construct(['node' => $node], ['with_parentheses' => false], $lineno); diff --git a/src/Node/SetNode.php b/src/Node/SetNode.php index 6e0661edb..4d97adb22 100644 --- a/src/Node/SetNode.php +++ b/src/Node/SetNode.php @@ -34,7 +34,7 @@ class SetNode extends Node implements NodeCaptureInterface if ($capture) { $safe = true; // Node::class === get_class($values) should be removed in Twig 4.0 - if (($values instanceof Nodes || Node::class === get_class($values)) && !count($values)) { + if (($values instanceof Nodes || Node::class === \get_class($values)) && !\count($values)) { $values = new ConstantExpression('', $values->getTemplateLine()); $capture = false; } elseif ($values instanceof TextNode) { diff --git a/src/TokenParser/GuardTokenParser.php b/src/TokenParser/GuardTokenParser.php index 17b221d4c..546ae7579 100644 --- a/src/TokenParser/GuardTokenParser.php +++ b/src/TokenParser/GuardTokenParser.php @@ -26,7 +26,7 @@ final class GuardTokenParser extends AbstractTokenParser { $stream = $this->parser->getStream(); $typeToken = $stream->expect(Token::NAME_TYPE); - if (!in_array($typeToken->getValue(), ['function', 'filter', 'test'])) { + if (!\in_array($typeToken->getValue(), ['function', 'filter', 'test'])) { throw new SyntaxError(\sprintf('Supported guard types are function, filter and test, "%s" given.', $typeToken->getValue()), $typeToken->getLine(), $stream->getSourceContext()); } $method = 'get'.$typeToken->getValue(); diff --git a/src/TokenParser/MacroTokenParser.php b/src/TokenParser/MacroTokenParser.php index 7d47821b2..33379be03 100644 --- a/src/TokenParser/MacroTokenParser.php +++ b/src/TokenParser/MacroTokenParser.php @@ -75,7 +75,7 @@ final class MacroTokenParser extends AbstractTokenParser $stream = $this->parser->getStream(); $stream->expect(Token::PUNCTUATION_TYPE, '(', 'A list of arguments must begin with an opening parenthesis'); while (!$stream->test(Token::PUNCTUATION_TYPE, ')')) { - if (count($arguments)) { + if (\count($arguments)) { $stream->expect(Token::PUNCTUATION_TYPE, ',', 'Arguments must be separated by a comma'); // if the comma above was a trailing comma, early exit the argument parse loop diff --git a/tests/NodeVisitor/OptimizerTest.php b/tests/NodeVisitor/OptimizerTest.php index 12bdc12d1..5964b7b48 100644 --- a/tests/NodeVisitor/OptimizerTest.php +++ b/tests/NodeVisitor/OptimizerTest.php @@ -70,7 +70,7 @@ class OptimizerTest extends TestCase public function checkForVarConfiguration(Node $node, $target) { foreach ($node as $n) { - if (NameExpression::class === get_class($n) && $target === $n->getAttribute('name')) { + if (NameExpression::class === \get_class($n) && $target === $n->getAttribute('name')) { $this->assertTrue($n->getAttribute('always_defined')); } else { $this->checkForVarConfiguration($n, $target);