Skip to content

Commit

Permalink
Add ForElseNode to avoid deprecation notice in Twig 3.19+
Browse files Browse the repository at this point in the history
  • Loading branch information
iquito committed Jan 30, 2025
1 parent 72c4f38 commit b71c2b5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 17 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": ">=8.0.2",
"twig/twig": "^3.15"
"twig/twig": "^3.19"
},
"require-dev": {
"captainhook/captainhook-phar": "^5.0",
Expand Down
3 changes: 2 additions & 1 deletion src/TokenParser/ForeachTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Twig\Lexer;
use Twig\Node\Expression\Variable\AssignContextVariable;
use Twig\Node\ForElseNode;
use Twig\Node\ForNode;
use Twig\Node\Node;
use Twig\Node\Nodes;
Expand All @@ -27,7 +28,7 @@ public function parse(Token $token): Node
$body = $this->parser->subparse([$this, 'decideForeachFork']);
if ($stream->next()->getValue() === 'else') {
$stream->expect(Token::BLOCK_END_TYPE);
$else = $this->parser->subparse([$this, 'decideForeachEnd'], true);
$else = new ForElseNode($this->parser->subparse([$this, 'decideForeachEnd'], true), $stream->getCurrent()->getLine());
} else {
$else = null;
}
Expand Down
6 changes: 0 additions & 6 deletions tools/phpstan-baseline.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
<?php declare(strict_types = 1);

$ignoreErrors = [];
$ignoreErrors[] = [
'message' => '#^Method Squirrel\\\\TwigPhpSyntax\\\\PhpSyntaxExtension\\:\\:getOperators\\(\\) has invalid return type Twig\\\\Extension\\\\OperatorPrecedenceChange\\.$#',
'identifier' => 'class.notFound',
'count' => 2,
'path' => __DIR__ . '/../src/PhpSyntaxExtension.php',
];
$ignoreErrors[] = [
'message' => '#^Method Squirrel\\\\TwigPhpSyntax\\\\PhpSyntaxExtension\\:\\:validateType\\(\\) should return bool\\|float\\|int\\|string\\|null but returns mixed\\.$#',
'identifier' => 'return.type',
Expand Down
10 changes: 1 addition & 9 deletions tools/psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
<file src="src/TokenParser/BreakOrContinueTokenParser.php">
<InternalMethod>
<code><![CDATA[getSourceContext]]></code>
<code><![CDATA[getSourceContext]]></code>
<code><![CDATA[getSourceContext]]></code>
</InternalMethod>
</file>
</files>
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0"/>

0 comments on commit b71c2b5

Please sign in to comment.