PHP Class Zephir\Variable

This represents a variable in a symbol table
Mostra file Open project: phalcon/zephir Class Usage Examples

Protected Properties

Property Type Description
$associatedClass Associated class
$branch zephir\Branch Branch where the variable was declared
$classTypes Class types
$defaultInitValue
$doublePointer
$dynamicTypes array Current dynamic type of the variable
$idle Temporal variables are marked as idle
$initBranch Branch where the variable was initialized for the first time
$initBranches
$initialized Whether the variable has received any assignment
$isExternal
$localOnly
$lowName Compiled variable's name
$memoryTracked
$mustInitNull
$name Variable's name
$node AST node where the variable was originally declared or created
$numberMutates Number of mutations to the variable
$numberSkips Initialization skips
$numberUses Number of times the variable has been read
$possibleValue Possible constant value assigned to the variable
$possibleValueBranch Branch where the variable got its last possible value
$readOnly
$reusable Reusable temporary variables?
$temporal Whether the variable is temporal or not
$type Variable's type
$used Whether the variable was used or not
$usedNode Last AST node where the variable was used
$variantInits

Public Methods

Method Description
__construct ( string $type, string $name, zephir\Branch $branch, mixed $defaultInitValue = null ) Variable constructor
enableDefaultAutoInitValue ( ) Sets an automatic safe default init value according to its type
getAssociatedClass ( ) : ClassDefinition Returns the class related to the variable
getBranch ( ) : zephir\Branch Get the branch where the variable was declared
getClassTypes ( ) : array Returns the PHP classes associated to the variable
getDefaultInitValue ( ) : mixed Returns the default init value
getDynamicTypes ( ) : array Returns the current dynamic type in a polymorphic variable
getInitBranch ( ) : boolean | integer Get init branch
getInitBranches ( ) : array Get init marked branch
getLastUsedNode ( ) : array Returns the last node where the variable was assigned or used
getName ( ) : string Returns variable's name
getNumberMutations ( ) : integer Returns the number of mutations performed over the variable
getNumberUses ( ) : integer Return the number of uses
getOriginal ( ) : array Returns the original AST node where the variable was declared
getPossibleValue ( ) : mixed Returns the latest CompiledExpression assigned to a variable
getPossibleValueBranch ( ) : zephir\Branch Returns the branch where the variable was assigned for the last time
getRealName ( ) : string Returns variable's real name
getSkipVariant ( ) : integer Get the number of initializations remaining to skip
getType ( ) : string Returns the type of variable
hasAnyDynamicType ( mixed $types ) : boolean Checks if the variable has any of the passed dynamic
hasDifferentDynamicType ( array | string $types ) : boolean Check if the variable has at least one dynamic type to the ones passed in the list
increaseMutates ( ) Increase the number of mutations a variable may have
increaseUses ( ) Increase the number of uses a variable may have
increaseVariantIfNull ( ) Increase the number of times the variable has been initialized
initComplexLiteralVariant ( zephir\CompilationContext $compilationContext ) Initializes a variant variable that is intended to have the special behavior of only freed its body value instead of the full variable
initNonReferenced ( zephir\CompilationContext $compilationContext ) * Allocate memory for variable and init it null val
initVariant ( zephir\CompilationContext $compilationContext ) Initializes a variant variable
isArray ( ) : boolean Shortcut is type double?
isBoolean ( ) : boolean Shortcut is type bool?
isDouble ( ) : boolean Shortcut is type double?
isDoublePointer ( ) Returns the variable
isExternal ( ) : boolean Check if the variable is a parameter
isIdle ( ) : boolean Checks if the variable is idle
isInitialized ( ) : boolean Check if the variable is initialized or not
isInt ( ) : boolean Shortcut is type int?
isLocalOnly ( ) : boolean Checks if the variable is local-only scoped
isMemoryTracked ( ) : boolean Checks if the variable is tracked by the memory manager
isNotVariable ( ) : boolean Shortcut is type variable or string?
isNotVariableAndArray ( ) : boolean Shortcut is type variable or array?
isNotVariableAndString ( ) : boolean Shortcut is type variable or string?
isReadOnly ( ) : boolean Returns if the variable is read only
isReusable ( ) : boolean Checks if the temporary variable is reusable
isString ( ) : boolean Shortcut is type string?
isTemporal ( ) : boolean Returns whether the variable is temporal or not
isUsed ( ) : boolean Checks whether the last value assigned was used
isVariable ( ) : boolean Shortcut is type variable?
mustInitNull ( ) : boolean Set if the variable must be initialized to null
observeOrNullifyVariant ( zephir\CompilationContext $compilationContext ) Observes a variable in the memory frame without initialization or nullify an existing allocated variable
observeVariant ( zephir\CompilationContext $compilationContext ) Observes a variable in the memory frame without initialization
separate ( zephir\CompilationContext $compilationContext ) Separates variables before being updated
setAssociatedClass ( ClassDefinition $associatedClass ) Sets the PHP class related to variable
setClassTypes ( string | array $classTypes ) Sets the PHP class related to variable
setDefaultInitValue ( mixed $value ) Sets the default init value
setDynamicTypes ( string | array $types ) Sets the current dynamic type in a polymorphic variable
setIdle ( boolean $idle ) Once a temporal variable is unused in a specific branch it is marked as idle
setIsDoublePointer ( boolean $doublePointer ) Marks the variable to be defined as a double pointer
setIsExternal ( boolean $isExternal ) Set if the symbol is a parameter of the method or not
setIsInitialized ( boolean $initialized, zephir\CompilationContext $compilationContext ) Sets if the variable is initialized This allow to throw an exception if the variable is being read without prior initialization
setLocalOnly ( boolean $localOnly ) Sets if the variable is local-only scoped
setLowName ( string $lowName ) Sets the compiled variable's name
setMemoryTracked ( boolean $memoryTracked ) Sets if the variable is not tracked by the memory manager
setMustInitNull ( boolean $mustInitNull ) : boolean Set if the variable must be initialized to null
setOriginal ( array $node ) Set the original AST node where the variable was declared
setPossibleValue ( zephir\CompiledExpression $possibleValue, zephir\CompilationContext $compilationContext ) Sets the latest CompiledExpression assigned to a variable
setReadOnly ( boolean $readOnly ) Sets if the variable is read only
setReusable ( boolean $reusable ) Some temporary variables can't be reused
setTemporal ( boolean $temporal ) Sets whether the variable is temporal or not
setUsed ( boolean $used, array $node ) Sets the latest node where a variable was used
skipInitVariant ( integer $numberSkips ) Skips variable initialization
trackVariant ( zephir\CompilationContext $compilationContext ) Tells the compiler a generated code will track the variable

Method Details

__construct() public method

Variable constructor
public __construct ( string $type, string $name, zephir\Branch $branch, mixed $defaultInitValue = null )
$type string
$name string
$branch zephir\Branch
$defaultInitValue mixed

enableDefaultAutoInitValue() public method

Sets an automatic safe default init value according to its type

getAssociatedClass() public method

Returns the class related to the variable
public getAssociatedClass ( ) : ClassDefinition
return ClassDefinition

getBranch() public method

Get the branch where the variable was declared
public getBranch ( ) : zephir\Branch
return zephir\Branch

getClassTypes() public method

Returns the PHP classes associated to the variable
public getClassTypes ( ) : array
return array

getDefaultInitValue() public method

Returns the default init value
public getDefaultInitValue ( ) : mixed
return mixed

getDynamicTypes() public method

Returns the current dynamic type in a polymorphic variable
public getDynamicTypes ( ) : array
return array

getInitBranch() public method

Get init branch
public getInitBranch ( ) : boolean | integer
return boolean | integer

getInitBranches() public method

Get init marked branch
public getInitBranches ( ) : array
return array

getLastUsedNode() public method

Returns the last node where the variable was assigned or used
public getLastUsedNode ( ) : array
return array

getName() public method

Returns variable's name
public getName ( ) : string
return string

getNumberMutations() public method

Returns the number of mutations performed over the variable
public getNumberMutations ( ) : integer
return integer

getNumberUses() public method

Return the number of uses
public getNumberUses ( ) : integer
return integer

getOriginal() public method

Returns the original AST node where the variable was declared
public getOriginal ( ) : array
return array

getPossibleValue() public method

Returns the latest CompiledExpression assigned to a variable
public getPossibleValue ( ) : mixed
return mixed

getPossibleValueBranch() public method

Returns the branch where the variable was assigned for the last time
public getPossibleValueBranch ( ) : zephir\Branch
return zephir\Branch

getRealName() public method

Returns variable's real name
public getRealName ( ) : string
return string

getSkipVariant() public method

Get the number of initializations remaining to skip
public getSkipVariant ( ) : integer
return integer

getType() public method

Returns the type of variable
public getType ( ) : string
return string

hasAnyDynamicType() public method

Checks if the variable has any of the passed dynamic
public hasAnyDynamicType ( mixed $types ) : boolean
$types mixed
return boolean

hasDifferentDynamicType() public method

Check if the variable has at least one dynamic type to the ones passed in the list
public hasDifferentDynamicType ( array | string $types ) : boolean
$types array | string
return boolean

increaseMutates() public method

Increase the number of mutations a variable may have
public increaseMutates ( )

increaseUses() public method

Increase the number of uses a variable may have
public increaseUses ( )

increaseVariantIfNull() public method

Increase the number of times the variable has been initialized

initComplexLiteralVariant() public method

Initializes a variant variable that is intended to have the special behavior of only freed its body value instead of the full variable
public initComplexLiteralVariant ( zephir\CompilationContext $compilationContext )
$compilationContext zephir\CompilationContext

initNonReferenced() public method

* Allocate memory for variable and init it null val
public initNonReferenced ( zephir\CompilationContext $compilationContext )
$compilationContext zephir\CompilationContext

initVariant() public method

Initializes a variant variable
public initVariant ( zephir\CompilationContext $compilationContext )
$compilationContext zephir\CompilationContext

isArray() public method

Shortcut is type double?
public isArray ( ) : boolean
return boolean

isBoolean() public method

Shortcut is type bool?
public isBoolean ( ) : boolean
return boolean

isDouble() public method

Shortcut is type double?
public isDouble ( ) : boolean
return boolean

isDoublePointer() public method

Returns the variable
public isDoublePointer ( )

isExternal() public method

Check if the variable is a parameter
public isExternal ( ) : boolean
return boolean

isIdle() public method

Checks if the variable is idle
public isIdle ( ) : boolean
return boolean

isInitialized() public method

Check if the variable is initialized or not
public isInitialized ( ) : boolean
return boolean

isInt() public method

Shortcut is type int?
public isInt ( ) : boolean
return boolean

isLocalOnly() public method

Checks if the variable is local-only scoped
public isLocalOnly ( ) : boolean
return boolean

isMemoryTracked() public method

Checks if the variable is tracked by the memory manager
public isMemoryTracked ( ) : boolean
return boolean

isNotVariable() public method

Shortcut is type variable or string?
public isNotVariable ( ) : boolean
return boolean

isNotVariableAndArray() public method

Shortcut is type variable or array?
public isNotVariableAndArray ( ) : boolean
return boolean

isNotVariableAndString() public method

Shortcut is type variable or string?
public isNotVariableAndString ( ) : boolean
return boolean

isReadOnly() public method

Returns if the variable is read only
public isReadOnly ( ) : boolean
return boolean

isReusable() public method

Checks if the temporary variable is reusable
public isReusable ( ) : boolean
return boolean

isString() public method

Shortcut is type string?
public isString ( ) : boolean
return boolean

isTemporal() public method

Returns whether the variable is temporal or not
public isTemporal ( ) : boolean
return boolean

isUsed() public method

Checks whether the last value assigned was used
public isUsed ( ) : boolean
return boolean

isVariable() public method

Shortcut is type variable?
public isVariable ( ) : boolean
return boolean

mustInitNull() public method

Set if the variable must be initialized to null
public mustInitNull ( ) : boolean
return boolean

observeOrNullifyVariant() public method

Observes a variable in the memory frame without initialization or nullify an existing allocated variable
public observeOrNullifyVariant ( zephir\CompilationContext $compilationContext )
$compilationContext zephir\CompilationContext

observeVariant() public method

Observes a variable in the memory frame without initialization
public observeVariant ( zephir\CompilationContext $compilationContext )
$compilationContext zephir\CompilationContext

separate() public method

Separates variables before being updated
public separate ( zephir\CompilationContext $compilationContext )
$compilationContext zephir\CompilationContext

setAssociatedClass() public method

Sets the PHP class related to variable
public setAssociatedClass ( ClassDefinition $associatedClass )
$associatedClass ClassDefinition

setClassTypes() public method

Sets the PHP class related to variable
public setClassTypes ( string | array $classTypes )
$classTypes string | array

setDefaultInitValue() public method

Sets the default init value
public setDefaultInitValue ( mixed $value )
$value mixed

setDynamicTypes() public method

Sets the current dynamic type in a polymorphic variable
public setDynamicTypes ( string | array $types )
$types string | array

setIdle() public method

Once a temporal variable is unused in a specific branch it is marked as idle
public setIdle ( boolean $idle )
$idle boolean

setIsDoublePointer() public method

Marks the variable to be defined as a double pointer
public setIsDoublePointer ( boolean $doublePointer )
$doublePointer boolean

setIsExternal() public method

Set if the symbol is a parameter of the method or not
public setIsExternal ( boolean $isExternal )
$isExternal boolean

setIsInitialized() public method

Sets if the variable is initialized This allow to throw an exception if the variable is being read without prior initialization
public setIsInitialized ( boolean $initialized, zephir\CompilationContext $compilationContext )
$initialized boolean
$compilationContext zephir\CompilationContext

setLocalOnly() public method

Sets if the variable is local-only scoped
public setLocalOnly ( boolean $localOnly )
$localOnly boolean

setLowName() public method

Sets the compiled variable's name
public setLowName ( string $lowName )
$lowName string

setMemoryTracked() public method

Sets if the variable is not tracked by the memory manager
public setMemoryTracked ( boolean $memoryTracked )
$memoryTracked boolean

setMustInitNull() public method

Set if the variable must be initialized to null
public setMustInitNull ( boolean $mustInitNull ) : boolean
$mustInitNull boolean
return boolean

setOriginal() public method

Set the original AST node where the variable was declared
public setOriginal ( array $node )
$node array

setPossibleValue() public method

Sets the latest CompiledExpression assigned to a variable
public setPossibleValue ( zephir\CompiledExpression $possibleValue, zephir\CompilationContext $compilationContext )
$possibleValue zephir\CompiledExpression
$compilationContext zephir\CompilationContext

setReadOnly() public method

Sets if the variable is read only
public setReadOnly ( boolean $readOnly )
$readOnly boolean

setReusable() public method

Some temporary variables can't be reused
public setReusable ( boolean $reusable )
$reusable boolean

setTemporal() public method

Sets whether the variable is temporal or not
public setTemporal ( boolean $temporal )
$temporal boolean

setUsed() public method

Sets the latest node where a variable was used
public setUsed ( boolean $used, array $node )
$used boolean
$node array

skipInitVariant() public method

Skips variable initialization
public skipInitVariant ( integer $numberSkips )
$numberSkips integer

trackVariant() public method

Tells the compiler a generated code will track the variable
public trackVariant ( zephir\CompilationContext $compilationContext )
$compilationContext zephir\CompilationContext

Property Details

$associatedClass protected_oe property

Associated class
protected $associatedClass

$branch protected_oe property

Branch where the variable was declared
protected Branch,zephir $branch
return zephir\Branch

$classTypes protected_oe property

Class types
protected $classTypes

$defaultInitValue protected_oe property

protected $defaultInitValue

$doublePointer protected_oe property

protected $doublePointer

$dynamicTypes protected_oe property

Current dynamic type of the variable
protected array $dynamicTypes
return array

$idle protected_oe property

Temporal variables are marked as idle
protected $idle

$initBranch protected_oe property

Branch where the variable was initialized for the first time
protected $initBranch

$initBranches protected_oe property

protected $initBranches

$initialized protected_oe property

Whether the variable has received any assignment
protected $initialized

$isExternal protected_oe property

protected $isExternal

$localOnly protected_oe property

protected $localOnly

$lowName protected_oe property

Compiled variable's name
protected $lowName

$memoryTracked protected_oe property

protected $memoryTracked

$mustInitNull protected_oe property

protected $mustInitNull

$name protected_oe property

Variable's name
protected $name

$node protected_oe property

AST node where the variable was originally declared or created
protected $node

$numberMutates protected_oe property

Number of mutations to the variable
protected $numberMutates

$numberSkips protected_oe property

Initialization skips
protected $numberSkips

$numberUses protected_oe property

Number of times the variable has been read
protected $numberUses

$possibleValue protected_oe property

Possible constant value assigned to the variable
protected $possibleValue

$possibleValueBranch protected_oe property

Branch where the variable got its last possible value
protected $possibleValueBranch

$readOnly protected_oe property

protected $readOnly

$reusable protected_oe property

Reusable temporary variables?
protected $reusable

$temporal protected_oe property

Whether the variable is temporal or not
protected $temporal

$type protected_oe property

Variable's type
protected $type

$used protected_oe property

Whether the variable was used or not
protected $used

$usedNode protected_oe property

Last AST node where the variable was used
protected $usedNode

$variantInits protected_oe property

protected $variantInits