Skip to content

Commit fbee0e2

Browse files
committed
Node: getIterator() must exists (BC break)
1 parent 49d2515 commit fbee0e2

18 files changed

Lines changed: 104 additions & 0 deletions

src/Latte/Compiler/Nodes/AuxiliaryNode.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,10 @@ public function print(PrintContext $context): string
2424
{
2525
return ($this->callable)($context);
2626
}
27+
28+
29+
public function &getIterator(): \Generator
30+
{
31+
false && yield;
32+
}
2733
}

src/Latte/Compiler/Nodes/NopNode.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@ public function print(PrintContext $context): string
1818
{
1919
return '';
2020
}
21+
22+
23+
public function &getIterator(): \Generator
24+
{
25+
false && yield;
26+
}
2127
}

src/Latte/Compiler/Nodes/Php/IdentifierNode.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,10 @@ public function print(PrintContext $context): string
3333
{
3434
return $this->name;
3535
}
36+
37+
38+
public function &getIterator(): \Generator
39+
{
40+
false && yield;
41+
}
3642
}

src/Latte/Compiler/Nodes/Php/NameNode.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,10 @@ public function toCodeString(): string
8686
};
8787
return $prefix . implode('\\', $this->parts);
8888
}
89+
90+
91+
public function &getIterator(): \Generator
92+
{
93+
false && yield;
94+
}
8995
}

src/Latte/Compiler/Nodes/Php/ScalarNode.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@
1212

1313
abstract class ScalarNode extends ExpressionNode
1414
{
15+
public function &getIterator(): \Generator
16+
{
17+
false && yield;
18+
}
1519
}

src/Latte/Compiler/Nodes/Php/SuperiorTypeNode.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,10 @@ public function print(PrintContext $context): string
2626
{
2727
throw new \LogicException('Cannot directly print SuperiorTypeNode');
2828
}
29+
30+
31+
public function &getIterator(): \Generator
32+
{
33+
false && yield;
34+
}
2935
}

src/Latte/Compiler/Nodes/TextNode.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,10 @@ public function isWhitespace(): bool
3434
{
3535
return trim($this->content) === '';
3636
}
37+
38+
39+
public function &getIterator(): \Generator
40+
{
41+
false && yield;
42+
}
3743
}

src/Latte/Compiler/TemplateParser.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ public function parseLatteStatement(): ?Node
238238
throw new \LogicException("Incorrect behavior of {{$startTag->name}} parser, unexpected returned value (on line {$startTag->position->line})");
239239
}
240240

241+
if ((new \ReflectionMethod($node, 'getIterator'))->getDeclaringClass()->getName() === Node::class) {
242+
trigger_error('Class ' . $node::class . ' should contain method getIterator(), see https://bit.ly/latte-666');
243+
}
244+
241245
if ($this->location === self::LocationHead && $startTag->outputMode !== $startTag::OutputNone) {
242246
$this->location = self::LocationText;
243247
}

src/Latte/Essential/Nodes/ContentTypeNode.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,10 @@ public function print(PrintContext $context): string
7171
)
7272
: '';
7373
}
74+
75+
76+
public function &getIterator(): \Generator
77+
{
78+
false && yield;
79+
}
7480
}

src/Latte/Essential/Nodes/RawPhpNode.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,10 @@ public function print(PrintContext $context): string
4343
$this->code,
4444
);
4545
}
46+
47+
48+
public function &getIterator(): \Generator
49+
{
50+
false && yield;
51+
}
4652
}

0 commit comments

Comments
 (0)