1: <?php declare(strict_types=1);
2:
3: namespace PhpParser\Node\Stmt;
4:
5: use PhpParser\Node;
6:
7: class For_ extends Node\Stmt
8: {
9: /** @var Node\Expr[] Init expressions */
10: public $init;
11: /** @var Node\Expr[] Loop conditions */
12: public $cond;
13: /** @var Node\Expr[] Loop expressions */
14: public $loop;
15: /** @var Node\Stmt[] Statements */
16: public $stmts;
17:
18: /**
19: * Constructs a for loop node.
20: *
21: * @param array $subNodes Array of the following optional subnodes:
22: * 'init' => array(): Init expressions
23: * 'cond' => array(): Loop conditions
24: * 'loop' => array(): Loop expressions
25: * 'stmts' => array(): Statements
26: * @param array $attributes Additional attributes
27: */
28: public function __construct(array $subNodes = [], array $attributes = []) {
29: $this->attributes = $attributes;
30: $this->init = $subNodes['init'] ?? [];
31: $this->cond = $subNodes['cond'] ?? [];
32: $this->loop = $subNodes['loop'] ?? [];
33: $this->stmts = $subNodes['stmts'] ?? [];
34: }
35:
36: public function getSubNodeNames() : array {
37: return ['init', 'cond', 'loop', 'stmts'];
38: }
39:
40: public function getType() : string {
41: return 'Stmt_For';
42: }
43: }
44: