Merge branch '1.x'

This commit is contained in:
Nikita Popov 2015-06-05 18:57:04 +02:00
commit db3dafd64d
4 changed files with 90 additions and 3 deletions

View File

@ -4,8 +4,9 @@ namespace PhpParser\Node\Expr;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\FunctionLike;
class Closure extends Expr
class Closure extends Expr implements FunctionLike
{
/** @var bool Whether the closure is static */
public $static;
@ -45,4 +46,20 @@ class Closure extends Expr
public function getSubNodeNames() {
return array('static', 'byRef', 'params', 'uses', 'returnType', 'stmts');
}
public function returnsByRef() {
return $this->byRef;
}
public function getParams() {
return $this->params;
}
public function getReturnType() {
return $this->returnType;
}
public function getStmts() {
return $this->stmts;
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace PhpParser\Node;
use PhpParser\Node;
interface FunctionLike extends Node
{
/**
* Whether to return by reference
*
* @return bool
*/
public function returnsByRef();
/**
* List of parameters
*
* @return Node\Param[]
*/
public function getParams();
/**
* Get the declared return type or null
*
* @return null|string|Node\Name[]
*/
public function getReturnType();
/**
* The function body
*
* @return Node\Stmt[]
*/
public function getStmts();
}

View File

@ -3,9 +3,10 @@
namespace PhpParser\Node\Stmt;
use PhpParser\Node;
use PhpParser\Node\FunctionLike;
use PhpParser\Error;
class ClassMethod extends Node\Stmt
class ClassMethod extends Node\Stmt implements FunctionLike
{
/** @var int Type */
public $type;
@ -57,6 +58,22 @@ class ClassMethod extends Node\Stmt
return array('type', 'byRef', 'name', 'params', 'returnType', 'stmts');
}
public function returnsByRef() {
return $this->byRef;
}
public function getParams() {
return $this->params;
}
public function getReturnType() {
return $this->returnType;
}
public function getStmts() {
return $this->stmts;
}
public function isPublic() {
return ($this->type & Class_::MODIFIER_PUBLIC) !== 0 || $this->type === 0;
}

View File

@ -3,8 +3,9 @@
namespace PhpParser\Node\Stmt;
use PhpParser\Node;
use PhpParser\Node\FunctionLike;
class Function_ extends Node\Stmt
class Function_ extends Node\Stmt implements FunctionLike
{
/** @var bool Whether function returns by reference */
public $byRef;
@ -40,4 +41,20 @@ class Function_ extends Node\Stmt
public function getSubNodeNames() {
return array('byRef', 'name', 'params', 'returnType', 'stmts');
}
public function returnsByRef() {
return $this->byRef;
}
public function getParams() {
return $this->params;
}
public function getReturnType() {
return $this->returnType;
}
public function getStmts() {
return $this->stmts;
}
}