1: | <?php declare(strict_types=1); |
2: | |
3: | namespace PhpParser\Node\Stmt; |
4: | |
5: | use PhpParser\Node; |
6: | |
7: | class Foreach_ extends Node\Stmt { |
8: | |
9: | public Node\Expr $expr; |
10: | |
11: | public ?Node\Expr $keyVar; |
12: | |
13: | public bool $byRef; |
14: | |
15: | public Node\Expr $valueVar; |
16: | |
17: | public array $stmts; |
18: | |
19: | |
20: | |
21: | |
22: | |
23: | |
24: | |
25: | |
26: | |
27: | |
28: | |
29: | |
30: | |
31: | |
32: | |
33: | |
34: | public function __construct(Node\Expr $expr, Node\Expr $valueVar, array $subNodes = [], array $attributes = []) { |
35: | $this->attributes = $attributes; |
36: | $this->expr = $expr; |
37: | $this->keyVar = $subNodes['keyVar'] ?? null; |
38: | $this->byRef = $subNodes['byRef'] ?? false; |
39: | $this->valueVar = $valueVar; |
40: | $this->stmts = $subNodes['stmts'] ?? []; |
41: | } |
42: | |
43: | public function getSubNodeNames(): array { |
44: | return ['expr', 'keyVar', 'byRef', 'valueVar', 'stmts']; |
45: | } |
46: | |
47: | public function getType(): string { |
48: | return 'Stmt_Foreach'; |
49: | } |
50: | } |
51: | |