mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-07 16:06:53 +00:00
Fix isset in ForLoopNode
Even though the code works perfectly fine, PHPStan doesn't understand it. Since we want to work with `revindex` and `revindex0`, we can better check for their existence, instead of `length`.
This commit is contained in:
@@ -38,7 +38,7 @@ class ForLoopNode extends Node
|
||||
->write("++\$context['loop']['index0'];\n")
|
||||
->write("++\$context['loop']['index'];\n")
|
||||
->write("\$context['loop']['first'] = false;\n")
|
||||
->write("if (isset(\$context['loop']['length'])) {\n")
|
||||
->write("if (isset(\$context['loop']['revindex0'], \$context['loop']['revindex'])) {\n")
|
||||
->indent()
|
||||
->write("--\$context['loop']['revindex0'];\n")
|
||||
->write("--\$context['loop']['revindex'];\n")
|
||||
|
||||
@@ -101,7 +101,7 @@ foreach (\$context['_seq'] as \$context["k"] => \$context["v"]) {
|
||||
++\$context['loop']['index0'];
|
||||
++\$context['loop']['index'];
|
||||
\$context['loop']['first'] = false;
|
||||
if (isset(\$context['loop']['length'])) {
|
||||
if (isset(\$context['loop']['revindex0'], \$context['loop']['revindex'])) {
|
||||
--\$context['loop']['revindex0'];
|
||||
--\$context['loop']['revindex'];
|
||||
\$context['loop']['last'] = 0 === \$context['loop']['revindex0'];
|
||||
@@ -143,7 +143,7 @@ foreach (\$context['_seq'] as \$context["k"] => \$context["v"]) {
|
||||
++\$context['loop']['index0'];
|
||||
++\$context['loop']['index'];
|
||||
\$context['loop']['first'] = false;
|
||||
if (isset(\$context['loop']['length'])) {
|
||||
if (isset(\$context['loop']['revindex0'], \$context['loop']['revindex'])) {
|
||||
--\$context['loop']['revindex0'];
|
||||
--\$context['loop']['revindex'];
|
||||
\$context['loop']['last'] = 0 === \$context['loop']['revindex0'];
|
||||
@@ -187,7 +187,7 @@ foreach (\$context['_seq'] as \$context["k"] => \$context["v"]) {
|
||||
++\$context['loop']['index0'];
|
||||
++\$context['loop']['index'];
|
||||
\$context['loop']['first'] = false;
|
||||
if (isset(\$context['loop']['length'])) {
|
||||
if (isset(\$context['loop']['revindex0'], \$context['loop']['revindex'])) {
|
||||
--\$context['loop']['revindex0'];
|
||||
--\$context['loop']['revindex'];
|
||||
\$context['loop']['last'] = 0 === \$context['loop']['revindex0'];
|
||||
|
||||
Reference in New Issue
Block a user