Skip to content

Commit b71c2b5

Browse files
committed
Add ForElseNode to avoid deprecation notice in Twig 3.19+
1 parent 72c4f38 commit b71c2b5

File tree

4 files changed

+4
-17
lines changed

4 files changed

+4
-17
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
],
1919
"require": {
2020
"php": ">=8.0.2",
21-
"twig/twig": "^3.15"
21+
"twig/twig": "^3.19"
2222
},
2323
"require-dev": {
2424
"captainhook/captainhook-phar": "^5.0",

src/TokenParser/ForeachTokenParser.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Twig\Lexer;
66
use Twig\Node\Expression\Variable\AssignContextVariable;
7+
use Twig\Node\ForElseNode;
78
use Twig\Node\ForNode;
89
use Twig\Node\Node;
910
use Twig\Node\Nodes;
@@ -27,7 +28,7 @@ public function parse(Token $token): Node
2728
$body = $this->parser->subparse([$this, 'decideForeachFork']);
2829
if ($stream->next()->getValue() === 'else') {
2930
$stream->expect(Token::BLOCK_END_TYPE);
30-
$else = $this->parser->subparse([$this, 'decideForeachEnd'], true);
31+
$else = new ForElseNode($this->parser->subparse([$this, 'decideForeachEnd'], true), $stream->getCurrent()->getLine());
3132
} else {
3233
$else = null;
3334
}

tools/phpstan-baseline.php

-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
<?php declare(strict_types = 1);
22

33
$ignoreErrors = [];
4-
$ignoreErrors[] = [
5-
'message' => '#^Method Squirrel\\\\TwigPhpSyntax\\\\PhpSyntaxExtension\\:\\:getOperators\\(\\) has invalid return type Twig\\\\Extension\\\\OperatorPrecedenceChange\\.$#',
6-
'identifier' => 'class.notFound',
7-
'count' => 2,
8-
'path' => __DIR__ . '/../src/PhpSyntaxExtension.php',
9-
];
104
$ignoreErrors[] = [
115
'message' => '#^Method Squirrel\\\\TwigPhpSyntax\\\\PhpSyntaxExtension\\:\\:validateType\\(\\) should return bool\\|float\\|int\\|string\\|null but returns mixed\\.$#',
126
'identifier' => 'return.type',

tools/psalm-baseline.xml

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
3-
<file src="src/TokenParser/BreakOrContinueTokenParser.php">
4-
<InternalMethod>
5-
<code><![CDATA[getSourceContext]]></code>
6-
<code><![CDATA[getSourceContext]]></code>
7-
<code><![CDATA[getSourceContext]]></code>
8-
</InternalMethod>
9-
</file>
10-
</files>
2+
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0"/>

0 commit comments

Comments
 (0)