Skip to content

Commit a2a4921

Browse files
committed
Remove deprecation code
1 parent 17ebb9a commit a2a4921

File tree

2 files changed

+8
-21
lines changed

2 files changed

+8
-21
lines changed

src/ExpressionParser.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ public function getFunctionNode($name, $line)
505505
return $node;
506506
}
507507

508-
$args = $this->parseArguments(true);
508+
$args = $this->parseArguments();
509509
$function = $this->getFunction($name, $line);
510510

511511
if ($function->getParserCallable()) {
@@ -615,7 +615,7 @@ public function parseFilterExpressionRaw($node)
615615
if (!$this->parser->getStream()->test(Token::PUNCTUATION_TYPE, '(')) {
616616
$arguments = new EmptyNode();
617617
} else {
618-
$arguments = $this->parseArguments(true);
618+
$arguments = $this->parseArguments();
619619
}
620620

621621
$filter = $this->getFilter($token->getValue(), $token->getLine());
@@ -635,19 +635,14 @@ public function parseFilterExpressionRaw($node)
635635
/**
636636
* Parses arguments.
637637
*
638-
* @param bool $namedArguments Whether to allow named arguments or not
639-
* @param bool $definition Whether we are parsing arguments for a function (or macro) definition
638+
* @param bool $definition Whether we are parsing arguments for a function (or macro) definition
640639
*
641640
* @return Node
642641
*
643642
* @throws SyntaxError
644643
*/
645-
public function parseArguments($namedArguments = false, $definition = false)
644+
public function parseArguments($namedArguments = true, $definition = false)
646645
{
647-
if (!$namedArguments) {
648-
trigger_deprecation('twig/twig', '3.15', 'Passing "false" for the first argument ($namedArguments) to "%s()" is deprecated.', __METHOD__);
649-
}
650-
651646
$args = [];
652647
$stream = $this->parser->getStream();
653648

@@ -678,7 +673,7 @@ public function parseArguments($namedArguments = false, $definition = false)
678673
}
679674

680675
$name = null;
681-
if ($namedArguments && (($token = $stream->nextIf(Token::OPERATOR_TYPE, '=')) || ($token = $stream->nextIf(Token::PUNCTUATION_TYPE, ':')))) {
676+
if (($token = $stream->nextIf(Token::OPERATOR_TYPE, '=')) || ($token = $stream->nextIf(Token::PUNCTUATION_TYPE, ':'))) {
682677
if (!$value instanceof NameExpression) {
683678
throw new SyntaxError(\sprintf('A parameter name must be a string, "%s" given.', $value::class), $token->getLine(), $stream->getSourceContext());
684679
}
@@ -766,7 +761,7 @@ private function parseTestExpression(Node $node): TestExpression
766761

767762
$arguments = null;
768763
if ($stream->test(Token::PUNCTUATION_TYPE, '(')) {
769-
$arguments = $this->parseArguments(true);
764+
$arguments = $this->parseArguments();
770765
} elseif ($test->hasOneMandatoryArgument()) {
771766
$arguments = new Nodes([0 => $this->getPrimary()]);
772767
}
@@ -883,7 +878,7 @@ private function setDeprecationCheck(bool $deprecationCheck): bool
883878
private function createArguments(int $line): ArrayExpression
884879
{
885880
$arguments = new ArrayExpression([], $line);
886-
foreach ($this->parseArguments(true) as $k => $n) {
881+
foreach ($this->parseArguments() as $k => $n) {
887882
$arguments->addElement($n, new TempNameExpression($k, $line));
888883
}
889884

src/Node/Expression/GetAttrExpression.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,13 @@
1818

1919
class GetAttrExpression extends AbstractExpression
2020
{
21-
22-
/**
23-
* @param ArrayExpression|NameExpression|null $arguments
24-
*/
25-
public function __construct(AbstractExpression $node, AbstractExpression $attribute, ?AbstractExpression $arguments, string $type, int $lineno)
21+
public function __construct(AbstractExpression $node, AbstractExpression $attribute, ArrayExpression|NameExpression|null $arguments, string $type, int $lineno)
2622
{
2723
$nodes = ['node' => $node, 'attribute' => $attribute];
2824
if (null !== $arguments) {
2925
$nodes['arguments'] = $arguments;
3026
}
3127

32-
if ($arguments && !$arguments instanceof ArrayExpression && !$arguments instanceof NameExpression) {
33-
trigger_deprecation('twig/twig', '3.15', \sprintf('Not passing a "%s" instance as the "arguments" argument of the "%s" constructor is deprecated ("%s" given).', ArrayExpression::class, static::class, $arguments::class));
34-
}
35-
3628
parent::__construct($nodes, ['type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'optimizable' => true], $lineno);
3729
}
3830

0 commit comments

Comments
 (0)