Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Nov 30, 2024
1 parent f0066c8 commit 4451613
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions src/ExpressionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function __construct(

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__);
}

Expand Down Expand Up @@ -153,7 +153,7 @@ private function triggerPrecedenceDeprecations(AbstractExpression $expr): void
/** @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')) {
Expand Down Expand Up @@ -616,10 +616,10 @@ public function parseArguments()
{
$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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Extension/CoreExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -1543,11 +1543,11 @@ public static function enumCases(string $enum): array
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];
Expand Down
4 changes: 2 additions & 2 deletions src/Node/Expression/Binary/AbstractBinary.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Node/Expression/BlockReferenceExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion src/Node/Expression/Filter/DefaultFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Node/Expression/Filter/RawFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/Node/Expression/FilterExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/Node/Expression/NullCoalesceExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public function __construct(Node $left, Node $right, int $lineno)
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());
Expand Down
4 changes: 2 additions & 2 deletions src/Node/Expression/TempNameExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public function __construct(string|int|null $name, int $lineno)
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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Node/Expression/Test/DefinedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Node/Expression/TestExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion src/Node/Expression/Unary/AbstractUnary.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Node/SetNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(bool $capture, Node $names, Node $values, int $linen
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) {
Expand Down
2 changes: 1 addition & 1 deletion src/TokenParser/GuardTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function parse(Token $token): Node
{
$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();
Expand Down
2 changes: 1 addition & 1 deletion src/TokenParser/MacroTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private function parseDefinition(): ArrayExpression
$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
Expand Down
2 changes: 1 addition & 1 deletion tests/NodeVisitor/OptimizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function testForVarOptimizer()
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);
Expand Down

0 comments on commit 4451613

Please sign in to comment.