mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-30 04:29:15 +01:00
Add NullableType to types of properties/args that offer it (#323)
This commit is contained in:
parent
aa6aec90e1
commit
030de805e1
@ -9,6 +9,8 @@ abstract class FunctionLike extends Declaration
|
||||
{
|
||||
protected $returnByRef = false;
|
||||
protected $params = array();
|
||||
|
||||
/** @var string|Node\Name|Node\NullableType|null */
|
||||
protected $returnType = null;
|
||||
|
||||
/**
|
||||
@ -59,7 +61,7 @@ abstract class FunctionLike extends Declaration
|
||||
/**
|
||||
* Sets the return type for PHP 7.
|
||||
*
|
||||
* @param string|Node\Name $type One of array, callable, string, int, float, bool, iterable,
|
||||
* @param string|Node\Name|Node\NullableType $type One of array, callable, string, int, float, bool, iterable,
|
||||
* or a class/interface name.
|
||||
*
|
||||
* @return $this The builder instance (for fluid interface)
|
||||
|
@ -10,6 +10,8 @@ class Method extends FunctionLike
|
||||
{
|
||||
protected $name;
|
||||
protected $flags = 0;
|
||||
|
||||
/** @var array|null */
|
||||
protected $stmts = array();
|
||||
|
||||
/**
|
||||
|
@ -10,7 +10,10 @@ class Param extends PhpParser\BuilderAbstract
|
||||
protected $name;
|
||||
|
||||
protected $default = null;
|
||||
|
||||
/** @var string|Node\Name|Node\NullableType|null */
|
||||
protected $type = null;
|
||||
|
||||
protected $byRef = false;
|
||||
|
||||
/**
|
||||
@ -38,7 +41,7 @@ class Param extends PhpParser\BuilderAbstract
|
||||
/**
|
||||
* Sets type hint for the parameter.
|
||||
*
|
||||
* @param string|Node\Name $type Type hint to use
|
||||
* @param string|Node\Name|Node\NullableType $type Type hint to use
|
||||
*
|
||||
* @return $this The builder instance (for fluid interface)
|
||||
*/
|
||||
|
@ -60,9 +60,9 @@ abstract class BuilderAbstract implements Builder {
|
||||
* In particular, builtin types are left as strings, custom types become Names and nullables
|
||||
* are wrapped in NullableType nodes.
|
||||
*
|
||||
* @param Name|string $type The type to normalize
|
||||
* @param Name|string|NullableType $type The type to normalize
|
||||
*
|
||||
* @return Name|string The normalized type
|
||||
* @return Name|string|NullableType The normalized type
|
||||
*/
|
||||
protected function normalizeType($type) {
|
||||
if (!is_string($type)) {
|
||||
|
@ -16,7 +16,7 @@ class Closure extends Expr implements FunctionLike
|
||||
public $params;
|
||||
/** @var ClosureUse[] use()s */
|
||||
public $uses;
|
||||
/** @var null|string|Node\Name Return type */
|
||||
/** @var null|string|Node\Name|Node\NullableType Return type */
|
||||
public $returnType;
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
|
@ -23,7 +23,7 @@ interface FunctionLike extends Node
|
||||
/**
|
||||
* Get the declared return type or null
|
||||
*
|
||||
* @return null|string|Node\Name
|
||||
* @return null|string|Node\Name|Node\NullableType
|
||||
*/
|
||||
public function getReturnType();
|
||||
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\NodeAbstract;
|
||||
|
||||
class Param extends NodeAbstract
|
||||
{
|
||||
/** @var null|string|Name Typehint */
|
||||
/** @var null|string|Name|NullableType Typehint */
|
||||
public $type;
|
||||
/** @var bool Whether parameter is passed by reference */
|
||||
public $byRef;
|
||||
@ -20,12 +20,12 @@ class Param extends NodeAbstract
|
||||
/**
|
||||
* Constructs a parameter node.
|
||||
*
|
||||
* @param string $name Name
|
||||
* @param null|Expr $default Default value
|
||||
* @param null|string|Name $type Typehint
|
||||
* @param bool $byRef Whether is passed by reference
|
||||
* @param bool $variadic Whether this is a variadic argument
|
||||
* @param array $attributes Additional attributes
|
||||
* @param string $name Name
|
||||
* @param null|Expr $default Default value
|
||||
* @param null|string|Name|NullableType $type Typehint
|
||||
* @param bool $byRef Whether is passed by reference
|
||||
* @param bool $variadic Whether this is a variadic argument
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, Expr $default = null, $type = null, $byRef = false, $variadic = false, array $attributes = array()) {
|
||||
parent::__construct($attributes);
|
||||
|
@ -15,7 +15,7 @@ class ClassMethod extends Node\Stmt implements FunctionLike
|
||||
public $name;
|
||||
/** @var Node\Param[] Parameters */
|
||||
public $params;
|
||||
/** @var null|string|Node\Name Return type */
|
||||
/** @var null|string|Node\Name|Node\NullableType Return type */
|
||||
public $returnType;
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
|
@ -13,7 +13,7 @@ class Function_ extends Node\Stmt implements FunctionLike
|
||||
public $name;
|
||||
/** @var Node\Param[] Parameters */
|
||||
public $params;
|
||||
/** @var null|string|Node\Name Return type */
|
||||
/** @var null|string|Node\Name|Node\NullableType Return type */
|
||||
public $returnType;
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
|
Loading…
Reference in New Issue
Block a user