PHP Class Phan\Language\Element\Variable

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

Public Methods

Method Description
__construct ( Context $context, string $name, UnionType $type, integer $flags )
__toString ( ) : string
asNonVariadic ( ) : static Stub for compatibility with Parameter, since we replace the Parameter with a Variable and call setParameterList in PostOrderAnalysisVisitor->visitStaticCall TODO: Should that code create a new Parameter instance instead?
fromNodeInContext ( ast\Node $node, Context $context, CodeBase $code_base, boolean $should_check_type = true ) : Variable
getUnionTypeOfHardcodedGlobalVariableWithName ( string $name, Context $context ) : UnionType | null
getVariadicElementUnionType ( ) : UnionType Variables can't be variadic. This is the same as getUnionType for variables, but not necessarily for subclasses. Method will return the element type (such as DateTime) for variadic parameters.
isHardcodedGlobalVariableWithName ( string $name ) : boolean Returns true for all superglobals and variables in globals_type_map.
isPassByReference ( ) : boolean
isSuperglobalVariableWithName ( string $name ) : boolean
isVariadic ( ) : boolean

Method Details

__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

Stub for compatibility with Parameter, since we replace the Parameter with a Variable and call setParameterList in PostOrderAnalysisVisitor->visitStaticCall TODO: Should that code create a new Parameter instance instead?
public asNonVariadic ( ) : static
return static

fromNodeInContext() public static method

public static fromNodeInContext ( ast\Node $node, Context $context, CodeBase $code_base, boolean $should_check_type = true ) : Variable
$node ast\Node An AST_VAR node
$context Phan\Language\Context The context in which the variable is found
$code_base Phan\CodeBase
$should_check_type boolean
return Variable A variable begotten from a node

getUnionTypeOfHardcodedGlobalVariableWithName() public static method

public static getUnionTypeOfHardcodedGlobalVariableWithName ( string $name, Context $context ) : UnionType | null
$name string
$context Phan\Language\Context
return Phan\Language\UnionType | null Returns UnionType (Possible with empty set) if and only if isHardcodedGlobalVariableWithName is true. Returns null otherwise.

getVariadicElementUnionType() public method

Variables can't be variadic. This is the same as getUnionType for variables, but not necessarily for subclasses. Method will return the element type (such as DateTime) for variadic parameters.
public getVariadicElementUnionType ( ) : UnionType
return Phan\Language\UnionType

isHardcodedGlobalVariableWithName() public static method

Returns true for all superglobals and variables in globals_type_map.
public static isHardcodedGlobalVariableWithName ( string $name ) : boolean
$name string
return boolean

isPassByReference() public method

public isPassByReference ( ) : boolean
return boolean This will always return false in so far as variables cannot be passed by reference.

isSuperglobalVariableWithName() public static method

public static isSuperglobalVariableWithName ( string $name ) : boolean
$name string
return boolean True if the variable with the given name is a superglobal Implies Variable::isHardcodedGlobalVariableWithName($name) is true

isVariadic() public method

public isVariadic ( ) : boolean
return boolean This will always return false in so far as variables cannot be variadic