PHP Class Phan\Language\Element\Parameter

Inheritance: extends Variable
Show file Open project: etsy/phan Class Usage Examples

Public Methods

Method Description
__clone ( ) : null After a clone is called on this object, clone our deep objects.
__construct ( Context $context, string $name, UnionType $type, integer $flags )
__toString ( ) : string
asNonVariadic ( ) : static Returns the Parameter in the form expected by a caller.
fromNode ( Context $context, CodeBase $code_base, ast\Node $node ) : Parameter
getDefaultValue ( ) : mixed
getDefaultValueType ( ) : UnionType
getUnionType ( ) : UnionType If this parameter is variadic (e.g. `DateTime .
getVariadicElementUnionType ( ) : UnionType If this Parameter is variadic, calling getUnionType will return an array type such as DateTime[]. This method will return the element type (such as DateTime) for variadic parameters.
hasDefaultValue ( ) : boolean
isOptional ( ) : boolean
isPassByReference ( ) : boolean
isRequired ( ) : boolean
isVariadic ( ) : boolean
listFromNode ( Context $context, CodeBase $code_base, ast\Node $node ) : array
setDefaultValue ( mixed $value ) : void
setDefaultValueType ( UnionType $type ) : void
setUnionType ( UnionType $type )

Method Details

__clone() public method

After a clone is called on this object, clone our deep objects.
public __clone ( ) : null
return null

__construct() public method

public __construct ( Context $context, string $name, UnionType $type, integer $flags )
$context Phan\Language\Context The context in which the structural element lives
$name string
$type Phan\Language\UnionType
$flags integer

__toString() public method

public __toString ( ) : string
return string

asNonVariadic() public method

If this parameter is variadic (e.g. DateTime ...$args), then this would return a parameter with the type of the elements (e.g. DateTime) If this parameter is not variadic, returns $this.
public asNonVariadic ( ) : static
return static (usually $this)

fromNode() public static method

See also: Phan\Deprecated\Pass1::node_param Formerly `function node_param`
public static fromNode ( Context $context, CodeBase $code_base, ast\Node $node ) : Parameter
$context Phan\Language\Context
$code_base Phan\CodeBase
$node ast\Node
return Parameter A parameter built from a node

getDefaultValue() public method

public getDefaultValue ( ) : mixed
return mixed The value of the default for this parameter if one is defined, otherwise null.

getDefaultValueType() public method

public getDefaultValueType ( ) : UnionType
return Phan\Language\UnionType The type of the default value for this parameter if it exists

getUnionType() public method

..$args), then this returns the corresponding array type(s) of $args. (e.g. DateTime[]) NOTE: For variadic arguments, this is a temporary variable. Modifying this won't result in persistent changes. (TODO(Issue #376) : We will probably want to be able to modify the underlying variable, e.g. by creating class UnionTypeGenericArrayView extends UnionType. Otherwise, type inference of ...$args` based on the function source will be less effective without phpdoc types.)
public getUnionType ( ) : UnionType
return Phan\Language\UnionType

getVariadicElementUnionType() public method

If this Parameter is variadic, calling getUnionType will return an array type such as DateTime[]. This method will return the element type (such as DateTime) for variadic parameters.
public getVariadicElementUnionType ( ) : UnionType
return Phan\Language\UnionType

hasDefaultValue() public method

public hasDefaultValue ( ) : boolean
return boolean True if this parameter has a type for its default value

isOptional() public method

public isOptional ( ) : boolean
return boolean True if this is an optional parameter

isPassByReference() public method

public isPassByReference ( ) : boolean
return boolean True if this parameter is pass-by-reference i.e. prefixed with '&'.

isRequired() public method

public isRequired ( ) : boolean
return boolean True if this is a required parameter

isVariadic() public method

public isVariadic ( ) : boolean
return boolean True if this parameter is variadic, i.e. can take an unlimited list of parameters and express them as an array.

listFromNode() public static method

See also: Phan\Deprecated\Pass1::node_paramlist Formerly `function node_paramlist`
public static listFromNode ( Context $context, CodeBase $code_base, ast\Node $node ) : array
$context Phan\Language\Context
$code_base Phan\CodeBase
$node ast\Node
return array A list of parameters from an AST node.

setDefaultValue() public method

public setDefaultValue ( mixed $value ) : void
$value mixed The value of the default for this parameter
return void

setDefaultValueType() public method

public setDefaultValueType ( UnionType $type ) : void
$type Phan\Language\UnionType The type of the default value for this parameter
return void

setUnionType() public method

public setUnionType ( UnionType $type )
$type Phan\Language\UnionType