PHP Class Zend\Code\Generator\ClassGenerator

Inheritance: extends Zend\Code\Generator\AbstractGenerator
显示文件 Open project: zendframework/zend-code Class Usage Examples

Protected Properties

Property Type Description
$constants Array of constants
$containingFileGenerator Zend\Code\Generator\FileGenerator
$docBlock Zend\Code\Generator\DocBlockGenerator
$extendedClass string
$flags boolean
$implementedInterfaces Array of string names
$methods Array of methods
$name string
$namespaceName string
$properties Array of properties
$traitUsageGenerator Object to encapsulate trait usage logic

Public Methods

Method Description
__construct ( string $name = null, string $namespaceName = null, array | string $flags = null, string $extends = null, array $interfaces = [], array $properties = [], array $methods = [], Zend\Code\Generator\DocBlockGenerator $docBlock = null )
addConstant ( string $name, string | integer | null | float | array $value ) : self Add Constant
addConstantFromGenerator ( Zend\Code\Generator\PropertyGenerator $constant ) : self Add constant from PropertyGenerator
addConstants ( array $constants ) : self
addFlag ( string $flag ) : self
addMethod ( string $name, array $parameters = [], integer $flags = MethodGenerator::FLAG_PUBLIC, string $body = null, string $docBlock = null ) : self Add Method from scalars
addMethodFromGenerator ( MethodGenerator $method ) : self Add Method from MethodGenerator
addMethods ( array $methods ) : self
addProperties ( array $properties ) : self
addProperty ( string $name, string | array $defaultValue = null, integer $flags = PropertyGenerator::FLAG_PUBLIC ) : self Add Property from scalars
addPropertyFromGenerator ( Zend\Code\Generator\PropertyGenerator $property ) : self Add property from PropertyGenerator
addTrait ( $trait )
addTraitAlias ( $method, $alias, $visibility = null )
addTraitOverride ( $method, $traitsToReplace )
addTraits ( array $traits )
addUse ( string $use, string | null $useAlias = null ) : self Add a class to "use" classes
fromArray ( array $array ) : self Generate from array
fromReflection ( Zend\Code\Reflection\ClassReflection $classReflection ) : self Build a Code Generation Php Object from a Class Reflection
generate ( )
getConstant ( string $constantName ) : Zend\Code\Generator\PropertyGenerator | false
getConstants ( ) : Zend\Code\Generator\PropertyGenerator[]
getContainingFileGenerator ( ) : Zend\Code\Generator\FileGenerator
getDocBlock ( ) : Zend\Code\Generator\DocBlockGenerator
getExtendedClass ( ) : string
getImplementedInterfaces ( ) : array
getMethod ( string $methodName ) : MethodGenerator | false
getMethods ( ) : MethodGenerator[]
getName ( ) : string
getNamespaceName ( ) : string
getProperties ( ) : Zend\Code\Generator\PropertyGenerator[]
getProperty ( string $propertyName ) : Zend\Code\Generator\PropertyGenerator | false
getTraitAliases ( )
getTraitOverrides ( )
getTraits ( )
getUses ( ) : array Returns the "use" classes
hasConstant ( string $constantName ) : boolean
hasExtentedClass ( ) : boolean
hasImplementedInterface ( string $implementedInterface ) : boolean
hasMethod ( string $methodName ) : boolean
hasProperty ( string $propertyName ) : boolean
hasTrait ( $traitName )
hasUse ( string $use ) : self
hasUseAlias ( string $use ) : boolean
isAbstract ( ) : boolean
isFinal ( ) : boolean
isSourceDirty ( ) : boolean
removeConstant ( string $constantName ) : self
removeExtentedClass ( ) : self
removeFlag ( string $flag ) : self
removeImplementedInterface ( $implementedInterface ) : self
removeMethod ( string $methodName ) : self
removeProperty ( string $propertyName ) : self
removeTrait ( $traitName )
removeTraitOverride ( $method, $overridesToRemove = null )
removeUse ( string $use ) : self
removeUseAlias ( $use ) : self
setAbstract ( boolean $isAbstract ) : self
setContainingFileGenerator ( Zend\Code\Generator\FileGenerator $fileGenerator ) : self
setDocBlock ( Zend\Code\Generator\DocBlockGenerator $docBlock ) : self
setExtendedClass ( string $extendedClass ) : self
setFinal ( boolean $isFinal ) : self
setFlags ( array | string $flags ) : self
setImplementedInterfaces ( array $implementedInterfaces ) : self
setName ( string $name ) : self
setNamespaceName ( string $namespaceName ) : self

Private Methods

Method Description
generateShortOrCompleteClassname ( string $fqnClassName ) : string
validateConstantValue ( mixed $value ) : void

Method Details

__construct() public method

public __construct ( string $name = null, string $namespaceName = null, array | string $flags = null, string $extends = null, array $interfaces = [], array $properties = [], array $methods = [], Zend\Code\Generator\DocBlockGenerator $docBlock = null )
$name string
$namespaceName string
$flags array | string
$extends string
$interfaces array
$properties array
$methods array
$docBlock Zend\Code\Generator\DocBlockGenerator

addConstant() public method

Add Constant
public addConstant ( string $name, string | integer | null | float | array $value ) : self
$name string non-empty string
$value string | integer | null | float | array scalar
return self

addConstantFromGenerator() public method

Add constant from PropertyGenerator
public addConstantFromGenerator ( Zend\Code\Generator\PropertyGenerator $constant ) : self
$constant Zend\Code\Generator\PropertyGenerator
return self

addConstants() public method

public addConstants ( array $constants ) : self
$constants array
return self

addFlag() public method

public addFlag ( string $flag ) : self
$flag string
return self

addMethod() public method

Add Method from scalars
public addMethod ( string $name, array $parameters = [], integer $flags = MethodGenerator::FLAG_PUBLIC, string $body = null, string $docBlock = null ) : self
$name string
$parameters array
$flags integer
$body string
$docBlock string
return self

addMethodFromGenerator() public method

Add Method from MethodGenerator
public addMethodFromGenerator ( MethodGenerator $method ) : self
$method MethodGenerator
return self

addMethods() public method

public addMethods ( array $methods ) : self
$methods array
return self

addProperties() public method

public addProperties ( array $properties ) : self
$properties array
return self

addProperty() public method

Add Property from scalars
public addProperty ( string $name, string | array $defaultValue = null, integer $flags = PropertyGenerator::FLAG_PUBLIC ) : self
$name string
$defaultValue string | array
$flags integer
return self

addPropertyFromGenerator() public method

Add property from PropertyGenerator
public addPropertyFromGenerator ( Zend\Code\Generator\PropertyGenerator $property ) : self
$property Zend\Code\Generator\PropertyGenerator
return self

addTrait() public method

public addTrait ( $trait )

addTraitAlias() public method

public addTraitAlias ( $method, $alias, $visibility = null )

addTraitOverride() public method

public addTraitOverride ( $method, $traitsToReplace )

addTraits() public method

public addTraits ( array $traits )
$traits array

addUse() public method

Add a class to "use" classes
public addUse ( string $use, string | null $useAlias = null ) : self
$use string
$useAlias string | null
return self

fromArray() public static method

Generate from array
public static fromArray ( array $array ) : self
$array array
return self

fromReflection() public static method

Build a Code Generation Php Object from a Class Reflection
public static fromReflection ( Zend\Code\Reflection\ClassReflection $classReflection ) : self
$classReflection Zend\Code\Reflection\ClassReflection
return self

generate() public method

public generate ( )

getConstant() public method

public getConstant ( string $constantName ) : Zend\Code\Generator\PropertyGenerator | false
$constantName string
return Zend\Code\Generator\PropertyGenerator | false

getConstants() public method

public getConstants ( ) : Zend\Code\Generator\PropertyGenerator[]
return Zend\Code\Generator\PropertyGenerator[] indexed by constant name

getContainingFileGenerator() public method

public getContainingFileGenerator ( ) : Zend\Code\Generator\FileGenerator
return Zend\Code\Generator\FileGenerator

getDocBlock() public method

public getDocBlock ( ) : Zend\Code\Generator\DocBlockGenerator
return Zend\Code\Generator\DocBlockGenerator

getExtendedClass() public method

public getExtendedClass ( ) : string
return string

getImplementedInterfaces() public method

public getImplementedInterfaces ( ) : array
return array

getMethod() public method

public getMethod ( string $methodName ) : MethodGenerator | false
$methodName string
return MethodGenerator | false

getMethods() public method

public getMethods ( ) : MethodGenerator[]
return MethodGenerator[]

getName() public method

public getName ( ) : string
return string

getNamespaceName() public method

public getNamespaceName ( ) : string
return string

getProperties() public method

public getProperties ( ) : Zend\Code\Generator\PropertyGenerator[]
return Zend\Code\Generator\PropertyGenerator[]

getProperty() public method

public getProperty ( string $propertyName ) : Zend\Code\Generator\PropertyGenerator | false
$propertyName string
return Zend\Code\Generator\PropertyGenerator | false

getTraitAliases() public method

public getTraitAliases ( )

getTraitOverrides() public method

public getTraitOverrides ( )

getTraits() public method

public getTraits ( )

getUses() public method

Returns the "use" classes
public getUses ( ) : array
return array

hasConstant() public method

public hasConstant ( string $constantName ) : boolean
$constantName string
return boolean

hasExtentedClass() public method

public hasExtentedClass ( ) : boolean
return boolean

hasImplementedInterface() public method

public hasImplementedInterface ( string $implementedInterface ) : boolean
$implementedInterface string
return boolean

hasMethod() public method

public hasMethod ( string $methodName ) : boolean
$methodName string
return boolean

hasProperty() public method

public hasProperty ( string $propertyName ) : boolean
$propertyName string
return boolean

hasTrait() public method

public hasTrait ( $traitName )

hasUse() public method

public hasUse ( string $use ) : self
$use string
return self

hasUseAlias() public method

public hasUseAlias ( string $use ) : boolean
$use string
return boolean

isAbstract() public method

public isAbstract ( ) : boolean
return boolean

isFinal() public method

public isFinal ( ) : boolean
return boolean

isSourceDirty() public method

public isSourceDirty ( ) : boolean
return boolean

removeConstant() public method

public removeConstant ( string $constantName ) : self
$constantName string
return self

removeExtentedClass() public method

public removeExtentedClass ( ) : self
return self

removeFlag() public method

public removeFlag ( string $flag ) : self
$flag string
return self

removeImplementedInterface() public method

public removeImplementedInterface ( $implementedInterface ) : self
$implementedInterface
return self

removeMethod() public method

public removeMethod ( string $methodName ) : self
$methodName string
return self

removeProperty() public method

public removeProperty ( string $propertyName ) : self
$propertyName string
return self

removeTrait() public method

public removeTrait ( $traitName )

removeTraitOverride() public method

public removeTraitOverride ( $method, $overridesToRemove = null )

removeUse() public method

public removeUse ( string $use ) : self
$use string
return self

removeUseAlias() public method

public removeUseAlias ( $use ) : self
$use
return self

setAbstract() public method

public setAbstract ( boolean $isAbstract ) : self
$isAbstract boolean
return self

setContainingFileGenerator() public method

public setContainingFileGenerator ( Zend\Code\Generator\FileGenerator $fileGenerator ) : self
$fileGenerator Zend\Code\Generator\FileGenerator
return self

setDocBlock() public method

public setDocBlock ( Zend\Code\Generator\DocBlockGenerator $docBlock ) : self
$docBlock Zend\Code\Generator\DocBlockGenerator
return self

setExtendedClass() public method

public setExtendedClass ( string $extendedClass ) : self
$extendedClass string
return self

setFinal() public method

public setFinal ( boolean $isFinal ) : self
$isFinal boolean
return self

setFlags() public method

public setFlags ( array | string $flags ) : self
$flags array | string
return self

setImplementedInterfaces() public method

public setImplementedInterfaces ( array $implementedInterfaces ) : self
$implementedInterfaces array
return self

setName() public method

public setName ( string $name ) : self
$name string
return self

setNamespaceName() public method

public setNamespaceName ( string $namespaceName ) : self
$namespaceName string
return self

Property Details

$constants protected_oe property

Array of constants
protected $constants

$containingFileGenerator protected_oe property

protected FileGenerator,Zend\Code\Generator $containingFileGenerator
return Zend\Code\Generator\FileGenerator

$docBlock protected_oe property

protected DocBlockGenerator,Zend\Code\Generator $docBlock
return Zend\Code\Generator\DocBlockGenerator

$extendedClass protected_oe property

protected string $extendedClass
return string

$flags protected_oe property

protected bool $flags
return boolean

$implementedInterfaces protected_oe property

Array of string names
protected $implementedInterfaces

$methods protected_oe property

Array of methods
protected $methods

$name protected_oe property

protected string $name
return string

$namespaceName protected_oe property

protected string $namespaceName
return string

$properties protected_oe property

Array of properties
protected $properties

$traitUsageGenerator protected_oe property

Object to encapsulate trait usage logic
protected $traitUsageGenerator