Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 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
    /** @var Node\Expr Expression to iterate */
10
    public $expr;
11
    /** @var null|Node\Expr Variable to assign key to */
12
    public $keyVar;
13
    /** @var bool Whether to assign value by reference */
14
    public $byRef;
15
    /** @var Node\Expr Variable to assign value to */
16
    public $valueVar;
17
    /** @var Node\Stmt[] Statements */
18
    public $stmts;
19
 
20
    /**
21
     * Constructs a foreach node.
22
     *
23
     * @param Node\Expr $expr       Expression to iterate
24
     * @param Node\Expr $valueVar   Variable to assign value to
25
     * @param array     $subNodes   Array of the following optional subnodes:
26
     *                              'keyVar' => null   : Variable to assign key to
27
     *                              'byRef'  => false  : Whether to assign value by reference
28
     *                              'stmts'  => array(): Statements
29
     * @param array     $attributes Additional attributes
30
     */
31
    public function __construct(Node\Expr $expr, Node\Expr $valueVar, array $subNodes = [], array $attributes = []) {
32
        $this->attributes = $attributes;
33
        $this->expr = $expr;
34
        $this->keyVar = $subNodes['keyVar'] ?? null;
35
        $this->byRef = $subNodes['byRef'] ?? false;
36
        $this->valueVar = $valueVar;
37
        $this->stmts = $subNodes['stmts'] ?? [];
38
    }
39
 
40
    public function getSubNodeNames() : array {
41
        return ['expr', 'keyVar', 'byRef', 'valueVar', 'stmts'];
42
    }
43
 
44
    public function getType() : string {
45
        return 'Stmt_Foreach';
46
    }
47
}