3 namespace PhpParser\Node\Expr;
6 use PhpParser\Node\Expr;
7 use PhpParser\Node\FunctionLike;
9 class Closure extends Expr implements FunctionLike
11 /** @var bool Whether the closure is static */
13 /** @var bool Whether to return by reference */
15 /** @var Node\Param[] Parameters */
17 /** @var ClosureUse[] use()s */
19 /** @var null|string|Node\Name|Node\NullableType Return type */
21 /** @var Node[] Statements */
25 * Constructs a lambda function node.
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
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();
46 public function getSubNodeNames() {
47 return array('static', 'byRef', 'params', 'uses', 'returnType', 'stmts');
50 public function returnsByRef() {
54 public function getParams() {
58 public function getReturnType() {
59 return $this->returnType;
62 public function getStmts() {