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\Expr;
4
 
5
use PhpParser\Node;
6
use PhpParser\Node\Expr;
7
use PhpParser\Node\FunctionLike;
8
 
9
class Closure extends Expr implements FunctionLike
10
{
11
    /** @var bool Whether the closure is static */
12
    public $static;
13
    /** @var bool Whether to return by reference */
14
    public $byRef;
15
    /** @var Node\Param[] Parameters */
16
    public $params;
17
    /** @var ClosureUse[] use()s */
18
    public $uses;
19
    /** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */
20
    public $returnType;
21
    /** @var Node\Stmt[] Statements */
22
    public $stmts;
23
    /** @var Node\AttributeGroup[] PHP attribute groups */
24
    public $attrGroups;
25
 
26
    /**
27
     * Constructs a lambda function node.
28
     *
29
     * @param array $subNodes   Array of the following optional subnodes:
30
     *                          'static'     => false  : Whether the closure is static
31
     *                          'byRef'      => false  : Whether to return by reference
32
     *                          'params'     => array(): Parameters
33
     *                          'uses'       => array(): use()s
34
     *                          'returnType' => null   : Return type
35
     *                          'stmts'      => array(): Statements
36
     *                          'attrGroups' => array(): PHP attributes groups
37
     * @param array $attributes Additional attributes
38
     */
39
    public function __construct(array $subNodes = [], array $attributes = []) {
40
        $this->attributes = $attributes;
41
        $this->static = $subNodes['static'] ?? false;
42
        $this->byRef = $subNodes['byRef'] ?? false;
43
        $this->params = $subNodes['params'] ?? [];
44
        $this->uses = $subNodes['uses'] ?? [];
45
        $returnType = $subNodes['returnType'] ?? null;
46
        $this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType;
47
        $this->stmts = $subNodes['stmts'] ?? [];
48
        $this->attrGroups = $subNodes['attrGroups'] ?? [];
49
    }
50
 
51
    public function getSubNodeNames() : array {
52
        return ['attrGroups', 'static', 'byRef', 'params', 'uses', 'returnType', 'stmts'];
53
    }
54
 
55
    public function returnsByRef() : bool {
56
        return $this->byRef;
57
    }
58
 
59
    public function getParams() : array {
60
        return $this->params;
61
    }
62
 
63
    public function getReturnType() {
64
        return $this->returnType;
65
    }
66
 
67
    /** @return Node\Stmt[] */
68
    public function getStmts() : array {
69
        return $this->stmts;
70
    }
71
 
72
    public function getAttrGroups() : array {
73
        return $this->attrGroups;
74
    }
75
 
76
    public function getType() : string {
77
        return 'Expr_Closure';
78
    }
79
}