5d376550854fdc0bd075825d7c9dc923db147dd6
[yaffs-website] / vendor / nikic / php-parser / lib / PhpParser / Node / Expr / Closure.php
1 <?php
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|string|Node\Name|Node\NullableType Return type */
20     public $returnType;
21     /** @var Node[] Statements */
22     public $stmts;
23
24     /**
25      * Constructs a lambda function node.
26      *
27      * @param array $subNodes   Array of the following optional subnodes:
28      *                          'static'     => false  : Whether the closure is static
29      *                          'byRef'      => false  : Whether to return by reference
30      *                          'params'     => array(): Parameters
31      *                          'uses'       => array(): use()s
32      *                          'returnType' => null   : Return type
33      *                          'stmts'      => array(): Statements
34      * @param array $attributes Additional attributes
35      */
36     public function __construct(array $subNodes = array(), array $attributes = array()) {
37         parent::__construct($attributes);
38         $this->static = isset($subNodes['static']) ? $subNodes['static'] : false;
39         $this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false;
40         $this->params = isset($subNodes['params']) ? $subNodes['params'] : array();
41         $this->uses = isset($subNodes['uses']) ? $subNodes['uses'] : array();
42         $this->returnType = isset($subNodes['returnType']) ? $subNodes['returnType'] : null;
43         $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
44     }
45
46     public function getSubNodeNames() {
47         return array('static', 'byRef', 'params', 'uses', 'returnType', 'stmts');
48     }
49
50     public function returnsByRef() {
51         return $this->byRef;
52     }
53
54     public function getParams() {
55         return $this->params;
56     }
57
58     public function getReturnType() {
59         return $this->returnType;
60     }
61
62     public function getStmts() {
63         return $this->stmts;
64     }
65 }