2011-10-26 18:34:12 +02:00
|
|
|
<?php
|
|
|
|
|
2014-02-06 14:44:16 +01:00
|
|
|
namespace PhpParser\Node\Expr;
|
|
|
|
|
|
|
|
use PhpParser\Node;
|
|
|
|
use PhpParser\Node\Expr;
|
|
|
|
|
|
|
|
class Closure extends Expr
|
2011-10-26 18:34:12 +02:00
|
|
|
{
|
2015-02-28 18:44:28 +01:00
|
|
|
/** @var bool Whether the closure is static */
|
|
|
|
public $static;
|
|
|
|
/** @var bool Whether to return by reference */
|
|
|
|
public $byRef;
|
|
|
|
/** @var Node\Param[] Parameters */
|
|
|
|
public $params;
|
|
|
|
/** @var ClosureUse[] use()s */
|
|
|
|
public $uses;
|
2015-03-12 13:17:31 +01:00
|
|
|
/** @var null|string|Node\Name[] Return type */
|
|
|
|
public $returnType;
|
2015-02-28 18:44:28 +01:00
|
|
|
/** @var Node[] Statements */
|
|
|
|
public $stmts;
|
|
|
|
|
2011-10-26 18:34:12 +02:00
|
|
|
/**
|
|
|
|
* Constructs a lambda function node.
|
|
|
|
*
|
2012-04-29 23:32:09 +02:00
|
|
|
* @param array $subNodes Array of the following optional subnodes:
|
2015-03-12 13:17:31 +01:00
|
|
|
* 'static' => false : Whether the closure is static
|
|
|
|
* 'byRef' => false : Whether to return by reference
|
|
|
|
* 'params' => array(): Parameters
|
|
|
|
* 'uses' => array(): use()s
|
|
|
|
* 'returnType' => null : Return type
|
|
|
|
* 'stmts' => array(): Statements
|
2012-04-29 23:32:09 +02:00
|
|
|
* @param array $attributes Additional attributes
|
2011-10-26 18:34:12 +02:00
|
|
|
*/
|
2012-04-29 23:32:09 +02:00
|
|
|
public function __construct(array $subNodes = array(), array $attributes = array()) {
|
2015-05-02 22:17:34 +02:00
|
|
|
parent::__construct($attributes);
|
2015-02-28 18:44:28 +01:00
|
|
|
$this->static = isset($subNodes['static']) ? $subNodes['static'] : false;
|
2015-03-12 13:17:31 +01:00
|
|
|
$this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false;
|
2015-02-28 18:44:28 +01:00
|
|
|
$this->params = isset($subNodes['params']) ? $subNodes['params'] : array();
|
2015-03-12 13:17:31 +01:00
|
|
|
$this->uses = isset($subNodes['uses']) ? $subNodes['uses'] : array();
|
|
|
|
$this->returnType = isset($subNodes['returnType']) ? $subNodes['returnType'] : null;
|
|
|
|
$this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
|
2015-02-28 18:44:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getSubNodeNames() {
|
2015-03-12 13:17:31 +01:00
|
|
|
return array('static', 'byRef', 'params', 'uses', 'returnType', 'stmts');
|
2011-10-26 18:34:12 +02:00
|
|
|
}
|
2015-02-28 18:44:28 +01:00
|
|
|
}
|