PHP Class Zephir\ClassDefinition

Represents a class/interface and their properties and methods
Exibir arquivo Open project: phalcon/zephir Class Usage Examples

Protected Properties

Property Type Description
$_aliasManager zephir\AliasManager
$abstract boolean
$compiler Compiler
$constants zephir\ClassConstant[]
$dependencyRank integer
$docBlock array
$eventsManager zephir\EventsManager
$extendsClass string
$extendsClassDefinition ClassDefinition
$external boolean
$final boolean
$implementedInterfaceDefinitions ClassDefinition[]
$interfaces array
$isBundled boolean
$isGeneratedConstructor boolean Whether the constructor was generated by zephir (-> no constructor existed previously)
$methods ClassMethod[]
$name string
$namespace string
$originalNode array
$parsedDocblock Zephir\Documentation\Docblock
$properties ClassProperty[]
$shortName string
$type string

Public Methods

Method Description
__construct ( string $namespace, string $name, string $shortName = null ) ClassDefinition
addConstant ( zephir\ClassConstant $constant ) Adds a constant to the definition
addInitMethod ( zephir\StatementsBlock $statementsBlock ) Creates the initialization method
addMethod ( ClassMethod $method, array $statement = null ) : void Adds a method to the class definition
addProperty ( ClassProperty $property ) Adds a property to the definition
addStaticInitMethod ( zephir\StatementsBlock $statementsBlock ) Creates the static initialization method
buildFromReflection ( ReflectionClass $class ) : ClassDefinition Builds a class definition from reflection
checkInterfaceImplements ( ClassDefinition $classDefinition, ClassDefinition $interfaceDefinition ) Checks if a class implements an interface
compile ( zephir\CompilationContext $compilationContext ) Compiles a class/interface
getAliasManager ( ) : zephir\AliasManager
getCNamespace ( ) : string Returns a valid namespace to be used in C-sources
getClassEntry ( zephir\CompilationContext $compilationContext = null ) : string Returns the name of the zend_class_entry according to the class name
getClassEntryByClassName ( string $className, zephir\CompilationContext $compilationContext, boolean $check = true ) : string Convert Class/Interface name to C ClassEntry
getCompleteName ( ) : string Returns the class name including its namespace
getConstant ( string $constantName ) : boolean | zephir\ClassConstant Returns a constant definition by its name
getConstants ( ) : zephir\ClassConstant[] Returns all constants defined in the class
getDependencies ( ) Calculate the dependency rank of the class based on its dependencies
getDependencyRank ( ) : integer Returns the dependency rank for this class
getDocBlock ( ) : array Returns the class/interface docBlock
getEventsManager ( ) : zephir\EventsManager Get eventsManager for class definition
getExtendsClass ( ) : string Returns the extended class
getExtendsClassDefinition ( ) : ClassDefinition Returns the class definition related to the extended class
getExternalHeader ( ) : string Returns an absolute location to the class header
getImplementedInterfaceDefinitions ( ) : ClassDefinition[] Returns the class definition for the implemented interfaces
getImplementedInterfaces ( ) : array Returns the implemented interfaces
getInitMethod ( ) : ClassMethod Returns the initialization method if any does exist
getLocalOrParentInitMethod ( ) : ClassMethod Returns the initialization method if any does exist
getMethod ( $methodName, boolean | true $checkExtends = true ) : boolean | ClassMethod Returns a method by its name
getMethods ( ) : ClassMethod[] Returns all methods defined in the class
getNCNamespace ( ) : string Returns a valid namespace to be used in C-sources
getName ( ) : string Returns the class name
getNamespace ( ) : string Return the class namespace
getParsedDocBlock ( ) : DocBlock Returns the parsed docBlock
getPossibleMethodName ( string $methodName ) : string | boolean Tries to find the most similar name
getProperties ( ) : ClassProperty[] Returns all properties defined in the class
getProperty ( $propertyName ) : boolean | ClassProperty Returns a method definition by its name
getSCName ( string $namespace ) : string Class name without namespace prefix for class registration
getShortName ( ) : string Returns the class name without namespace
getStaticInitMethod ( ) : ClassMethod Returns the initialization method if any does exist
getType ( ) : string Returns the class type
hasConstant ( string $name ) : boolean Checks if class definition has a property
hasMethod ( $methodName ) : boolean Checks if the class implements an specific name
hasProperty ( string $name ) : boolean Checks if a class definition has a property
increaseDependencyRank ( integer $rank ) A class definition calls this method to mark this class as a dependency of another
isAbstract ( ) : boolean Checks whether the class is abstract or not
isBundled ( ) : boolean Returns whether the class is bundled or not
isExternal ( ) : boolean Returns whether the class is internal or not
isFinal ( ) : boolean Checks whether the class is abstract or not
isGeneratedConstructor ( ) : boolean Returns whether the constructor was generated by zephir
isInterface ( ) : boolean Check if the class definition correspond to an interface
preCompile ( zephir\CompilationContext $compilationContext ) Pre-compiles a class/interface gathering method information required by other methods
setAliasManager ( zephir\AliasManager $aliasManager )
setDocBlock ( array $docBlock ) Sets the class/interface docBlock
setExtendsClass ( string $extendsClass ) Sets the extended class
setExtendsClassDefinition ( $classDefinition ) Sets the class definition for the extended class
setImplementedInterfaceDefinitions ( array $implementedInterfaceDefinitions ) Sets the class definition for the implemented interfaces
setImplementsInterfaces ( array $implementedInterfaces ) Sets the implemented interfaces
setIsAbstract ( boolean $abstract ) Sets if the class is final
setIsBundled ( boolean $isBundled ) Sets if the class is internal or not
setIsExternal ( boolean $isExternal ) Sets whether the class is external or not
setIsFinal ( boolean $final ) Sets if the class is final
setIsGeneratedConstructor ( boolean $isGeneratedConstructor ) Sets if the class constructor was generated by zephir
setMethod ( $methodName, ClassMethod $method ) Set a method and its body
setMethods ( array $methods ) Sets class methods externally
setOriginalNode ( array $originalNode ) Set the original node where the class was declared
setType ( string $type ) Set the class' type (class/interface)
updateMethod ( ClassMethod $method, array $statement = null ) : void Updates an existing method definition

Protected Methods

Method Description
getConstantFromInterfaces ( $name ) : boolean | zephir\ClassConstant
hasConstantFromInterfaces ( $name ) : boolean

Private Methods

Method Description
_convertPhpConstantType ( $phpType )

Method Details

__construct() public method

ClassDefinition
public __construct ( string $namespace, string $name, string $shortName = null )
$namespace string
$name string
$shortName string

addConstant() public method

Adds a constant to the definition
public addConstant ( zephir\ClassConstant $constant )
$constant zephir\ClassConstant

addInitMethod() public method

Creates the initialization method
public addInitMethod ( zephir\StatementsBlock $statementsBlock )
$statementsBlock zephir\StatementsBlock

addMethod() public method

Adds a method to the class definition
public addMethod ( ClassMethod $method, array $statement = null ) : void
$method ClassMethod
$statement array
return void

addProperty() public method

Adds a property to the definition
public addProperty ( ClassProperty $property )
$property ClassProperty

addStaticInitMethod() public method

Creates the static initialization method
public addStaticInitMethod ( zephir\StatementsBlock $statementsBlock )
$statementsBlock zephir\StatementsBlock

buildFromReflection() public static method

Builds a class definition from reflection
public static buildFromReflection ( ReflectionClass $class ) : ClassDefinition
$class ReflectionClass
return ClassDefinition

checkInterfaceImplements() public method

Checks if a class implements an interface
public checkInterfaceImplements ( ClassDefinition $classDefinition, ClassDefinition $interfaceDefinition )
$classDefinition ClassDefinition
$interfaceDefinition ClassDefinition

compile() public method

Compiles a class/interface
public compile ( zephir\CompilationContext $compilationContext )
$compilationContext zephir\CompilationContext

getAliasManager() public method

public getAliasManager ( ) : zephir\AliasManager
return zephir\AliasManager

getCNamespace() public method

Returns a valid namespace to be used in C-sources
public getCNamespace ( ) : string
return string

getClassEntry() public method

Returns the name of the zend_class_entry according to the class name
public getClassEntry ( zephir\CompilationContext $compilationContext = null ) : string
$compilationContext zephir\CompilationContext
return string

getClassEntryByClassName() public method

Convert Class/Interface name to C ClassEntry
public getClassEntryByClassName ( string $className, zephir\CompilationContext $compilationContext, boolean $check = true ) : string
$className string
$compilationContext zephir\CompilationContext
$check boolean
return string

getCompleteName() public method

Returns the class name including its namespace
public getCompleteName ( ) : string
return string

getConstant() public method

Returns a constant definition by its name
public getConstant ( string $constantName ) : boolean | zephir\ClassConstant
$constantName string
return boolean | zephir\ClassConstant

getConstantFromInterfaces() protected method

protected getConstantFromInterfaces ( $name ) : boolean | zephir\ClassConstant
$name
return boolean | zephir\ClassConstant

getConstants() public method

Returns all constants defined in the class
public getConstants ( ) : zephir\ClassConstant[]
return zephir\ClassConstant[]

getDependencies() public method

Calculate the dependency rank of the class based on its dependencies
public getDependencies ( )

getDependencyRank() public method

Returns the dependency rank for this class
public getDependencyRank ( ) : integer
return integer

getDocBlock() public method

Returns the class/interface docBlock
public getDocBlock ( ) : array
return array

getEventsManager() public method

Get eventsManager for class definition
public getEventsManager ( ) : zephir\EventsManager
return zephir\EventsManager

getExtendsClass() public method

Returns the extended class
public getExtendsClass ( ) : string
return string

getExtendsClassDefinition() public method

Returns the class definition related to the extended class
public getExtendsClassDefinition ( ) : ClassDefinition
return ClassDefinition

getExternalHeader() public method

Returns an absolute location to the class header
public getExternalHeader ( ) : string
return string

getImplementedInterfaceDefinitions() public method

Returns the class definition for the implemented interfaces
public getImplementedInterfaceDefinitions ( ) : ClassDefinition[]
return ClassDefinition[]

getImplementedInterfaces() public method

Returns the implemented interfaces
public getImplementedInterfaces ( ) : array
return array

getInitMethod() public method

Returns the initialization method if any does exist
public getInitMethod ( ) : ClassMethod
return ClassMethod

getLocalOrParentInitMethod() public method

Returns the initialization method if any does exist
public getLocalOrParentInitMethod ( ) : ClassMethod
return ClassMethod

getMethod() public method

Returns a method by its name
public getMethod ( $methodName, boolean | true $checkExtends = true ) : boolean | ClassMethod
$checkExtends boolean | true
return boolean | ClassMethod

getMethods() public method

Returns all methods defined in the class
public getMethods ( ) : ClassMethod[]
return ClassMethod[]

getNCNamespace() public method

Returns a valid namespace to be used in C-sources
public getNCNamespace ( ) : string
return string

getName() public method

Returns the class name
public getName ( ) : string
return string

getNamespace() public method

Return the class namespace
public getNamespace ( ) : string
return string

getParsedDocBlock() public method

Returns the parsed docBlock
public getParsedDocBlock ( ) : DocBlock
return DocBlock

getPossibleMethodName() public method

Tries to find the most similar name
public getPossibleMethodName ( string $methodName ) : string | boolean
$methodName string
return string | boolean

getProperties() public method

Returns all properties defined in the class
public getProperties ( ) : ClassProperty[]
return ClassProperty[]

getProperty() public method

Returns a method definition by its name
public getProperty ( $propertyName ) : boolean | ClassProperty
return boolean | ClassProperty

getSCName() public method

Class name without namespace prefix for class registration
public getSCName ( string $namespace ) : string
$namespace string
return string

getShortName() public method

Returns the class name without namespace
public getShortName ( ) : string
return string

getStaticInitMethod() public method

Returns the initialization method if any does exist
public getStaticInitMethod ( ) : ClassMethod
return ClassMethod

getType() public method

Returns the class type
public getType ( ) : string
return string

hasConstant() public method

Checks if class definition has a property
public hasConstant ( string $name ) : boolean
$name string
return boolean

hasConstantFromInterfaces() protected method

protected hasConstantFromInterfaces ( $name ) : boolean
$name
return boolean

hasMethod() public method

Checks if the class implements an specific name
public hasMethod ( $methodName ) : boolean
return boolean

hasProperty() public method

Checks if a class definition has a property
public hasProperty ( string $name ) : boolean
$name string
return boolean

increaseDependencyRank() public method

A class definition calls this method to mark this class as a dependency of another
public increaseDependencyRank ( integer $rank )
$rank integer

isAbstract() public method

Checks whether the class is abstract or not
public isAbstract ( ) : boolean
return boolean

isBundled() public method

Returns whether the class is bundled or not
public isBundled ( ) : boolean
return boolean

isExternal() public method

Returns whether the class is internal or not
public isExternal ( ) : boolean
return boolean

isFinal() public method

Checks whether the class is abstract or not
public isFinal ( ) : boolean
return boolean

isGeneratedConstructor() public method

Returns whether the constructor was generated by zephir
public isGeneratedConstructor ( ) : boolean
return boolean

isInterface() public method

Check if the class definition correspond to an interface
public isInterface ( ) : boolean
return boolean

preCompile() public method

Pre-compiles a class/interface gathering method information required by other methods
public preCompile ( zephir\CompilationContext $compilationContext )
$compilationContext zephir\CompilationContext

setAliasManager() public method

public setAliasManager ( zephir\AliasManager $aliasManager )
$aliasManager zephir\AliasManager

setDocBlock() public method

Sets the class/interface docBlock
public setDocBlock ( array $docBlock )
$docBlock array

setExtendsClass() public method

Sets the extended class
public setExtendsClass ( string $extendsClass )
$extendsClass string

setExtendsClassDefinition() public method

Sets the class definition for the extended class
public setExtendsClassDefinition ( $classDefinition )
$classDefinition

setImplementedInterfaceDefinitions() public method

Sets the class definition for the implemented interfaces
public setImplementedInterfaceDefinitions ( array $implementedInterfaceDefinitions )
$implementedInterfaceDefinitions array

setImplementsInterfaces() public method

Sets the implemented interfaces
public setImplementsInterfaces ( array $implementedInterfaces )
$implementedInterfaces array

setIsAbstract() public method

Sets if the class is final
public setIsAbstract ( boolean $abstract )
$abstract boolean

setIsBundled() public method

Sets if the class is internal or not
public setIsBundled ( boolean $isBundled )
$isBundled boolean

setIsExternal() public method

Sets whether the class is external or not
public setIsExternal ( boolean $isExternal )
$isExternal boolean

setIsFinal() public method

Sets if the class is final
public setIsFinal ( boolean $final )
$final boolean

setIsGeneratedConstructor() public method

Sets if the class constructor was generated by zephir
public setIsGeneratedConstructor ( boolean $isGeneratedConstructor )
$isGeneratedConstructor boolean

setMethod() public method

Set a method and its body
public setMethod ( $methodName, ClassMethod $method )
$methodName
$method ClassMethod

setMethods() public method

Sets class methods externally
public setMethods ( array $methods )
$methods array

setOriginalNode() public method

Set the original node where the class was declared
public setOriginalNode ( array $originalNode )
$originalNode array

setType() public method

Set the class' type (class/interface)
public setType ( string $type )
$type string

updateMethod() public method

Updates an existing method definition
public updateMethod ( ClassMethod $method, array $statement = null ) : void
$method ClassMethod
$statement array
return void

Property Details

$_aliasManager protected_oe property

protected AliasManager,zephir $_aliasManager
return zephir\AliasManager

$abstract protected_oe property

protected bool $abstract
return boolean

$compiler protected_oe property

protected Compiler,zephir $compiler
return Compiler

$constants protected_oe property

protected ClassConstant[],zephir $constants
return zephir\ClassConstant[]

$dependencyRank protected_oe property

protected int $dependencyRank
return integer

$docBlock protected_oe property

protected array $docBlock
return array

$eventsManager protected_oe property

protected EventsManager,zephir $eventsManager
return zephir\EventsManager

$extendsClass protected_oe property

protected string $extendsClass
return string

$extendsClassDefinition protected_oe property

protected ClassDefinition,zephir $extendsClassDefinition
return ClassDefinition

$external protected_oe property

protected bool $external
return boolean

$final protected_oe property

protected bool $final
return boolean

$implementedInterfaceDefinitions protected_oe property

protected ClassDefinition[],zephir $implementedInterfaceDefinitions
return ClassDefinition[]

$interfaces protected_oe property

protected array $interfaces
return array

$isBundled protected_oe property

protected bool $isBundled
return boolean

$isGeneratedConstructor protected_oe property

Whether the constructor was generated by zephir (-> no constructor existed previously)
protected bool $isGeneratedConstructor
return boolean

$methods protected_oe property

protected ClassMethod[],zephir $methods
return ClassMethod[]

$name protected_oe property

protected string $name
return string

$namespace protected_oe property

protected string $namespace
return string

$originalNode protected_oe property

protected array $originalNode
return array

$parsedDocblock protected_oe property

protected Docblock,Zephir\Documentation $parsedDocblock
return Zephir\Documentation\Docblock

$properties protected_oe property

protected ClassProperty[],zephir $properties
return ClassProperty[]

$shortName protected_oe property

protected string $shortName
return string

$type protected_oe property

protected string $type
return string