2011-05-27 18:20:44 +02:00
|
|
|
<?php
|
|
|
|
|
2014-02-06 14:44:16 +01:00
|
|
|
namespace PhpParser\Node\Stmt;
|
|
|
|
|
|
|
|
use PhpParser\Node;
|
2015-06-01 18:32:25 +02:00
|
|
|
use PhpParser\Node\FunctionLike;
|
2014-02-06 14:44:16 +01:00
|
|
|
|
2015-06-01 18:32:25 +02:00
|
|
|
class Function_ extends Node\Stmt implements FunctionLike
|
2011-05-27 18:20:44 +02:00
|
|
|
{
|
2015-02-28 18:44:28 +01:00
|
|
|
/** @var bool Whether function returns by reference */
|
|
|
|
public $byRef;
|
|
|
|
/** @var string Name */
|
|
|
|
public $name;
|
|
|
|
/** @var Node\Param[] Parameters */
|
|
|
|
public $params;
|
2015-07-02 18:06:41 +02:00
|
|
|
/** @var null|string|Node\Name Return type */
|
2015-03-12 13:17:31 +01:00
|
|
|
public $returnType;
|
2015-02-28 18:44:28 +01:00
|
|
|
/** @var Node[] Statements */
|
|
|
|
public $stmts;
|
|
|
|
|
2011-10-28 19:06:24 +02:00
|
|
|
/**
|
|
|
|
* Constructs a function node.
|
|
|
|
*
|
2012-04-29 23:32:09 +02:00
|
|
|
* @param string $name Name
|
|
|
|
* @param array $subNodes Array of the following optional subnodes:
|
2015-03-12 13:17:31 +01:00
|
|
|
* 'byRef' => false : Whether to return by reference
|
|
|
|
* 'params' => array(): Parameters
|
|
|
|
* 'returnType' => null : Return type
|
|
|
|
* 'stmts' => array(): Statements
|
2012-04-29 23:32:09 +02:00
|
|
|
* @param array $attributes Additional attributes
|
2011-10-28 19:06:24 +02:00
|
|
|
*/
|
2012-04-29 23:32:09 +02:00
|
|
|
public function __construct($name, array $subNodes = array(), array $attributes = array()) {
|
2015-02-28 18:44:28 +01:00
|
|
|
parent::__construct(null, $attributes);
|
|
|
|
$this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false;
|
2011-10-28 19:06:24 +02:00
|
|
|
$this->name = $name;
|
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->returnType = isset($subNodes['returnType']) ? $subNodes['returnType'] : null;
|
2015-02-28 18:44:28 +01:00
|
|
|
$this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSubNodeNames() {
|
2015-03-12 13:17:31 +01:00
|
|
|
return array('byRef', 'name', 'params', 'returnType', 'stmts');
|
2011-10-28 19:06:24 +02:00
|
|
|
}
|
2015-06-01 18:32:25 +02:00
|
|
|
|
|
|
|
public function returnsByRef() {
|
|
|
|
return $this->byRef;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getParams() {
|
|
|
|
return $this->params;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getReturnType() {
|
|
|
|
return $this->returnType;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getStmts() {
|
|
|
|
return $this->stmts;
|
|
|
|
}
|
2015-02-28 18:44:28 +01:00
|
|
|
}
|