Zend Framework  3.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
ClassGenerator Class Reference

Public Member Functions

 __construct ($name=null, $namespaceName=null, $flags=null, $extends=null, $interfaces=[], $properties=[], $methods=[], $docBlock=null)
 
 setName ($name)
 
 getName ()
 
 setNamespaceName ($namespaceName)
 
 getNamespaceName ()
 
 setContainingFileGenerator (FileGenerator $fileGenerator)
 
 getContainingFileGenerator ()
 
 setDocBlock (DocBlockGenerator $docBlock)
 
 getDocBlock ()
 
 setFlags ($flags)
 
 addFlag ($flag)
 
 removeFlag ($flag)
 
 setAbstract ($isAbstract)
 
 isAbstract ()
 
 setFinal ($isFinal)
 
 isFinal ()
 
 setExtendedClass ($extendedClass)
 
 getExtendedClass ()
 
 setImplementedInterfaces (array $implementedInterfaces)
 
 getImplementedInterfaces ()
 
 getConstant ($constantName)
 
 getConstants ()
 
 hasConstant ($constantName)
 
 addConstantFromGenerator (PropertyGenerator $constant)
 Add constant from PropertyGenerator.
 
 addConstant ($name, $value)
 Add Constant.
 
 addConstants (array $constants)
 
 addProperties (array $properties)
 
 addProperty ($name, $defaultValue=null, $flags=PropertyGenerator::FLAG_PUBLIC)
 Add Property from scalars.
 
 addPropertyFromGenerator (PropertyGenerator $property)
 Add property from PropertyGenerator.
 
 getProperties ()
 
 getProperty ($propertyName)
 
 addUse ($use, $useAlias=null)
 Add a class to "use" classes.
 
 getUses ()
 Returns the "use" classes.
 
 hasProperty ($propertyName)
 
 addMethods (array $methods)
 
 addMethod ($name, array $parameters=[], $flags=MethodGenerator::FLAG_PUBLIC, $body=null, $docBlock=null)
 Add Method from scalars.
 
 addMethodFromGenerator (MethodGenerator $method)
 Add Method from MethodGenerator.
 
 getMethods ()
 
 getMethod ($methodName)
 
 removeMethod ($methodName)
 
 hasMethod ($methodName)
 
 addTrait ($trait)
 
 addTraits (array $traits)
 
 hasTrait ($traitName)
 
 getTraits ()
 
 removeTrait ($traitName)
 
 addTraitAlias ($method, $alias, $visibility=null)
 
 getTraitAliases ()
 
 addTraitOverride ($method, $traitsToReplace)
 
 removeTraitOverride ($method, $overridesToRemove=null)
 
 getTraitOverrides ()
 
 isSourceDirty ()
 
 generate ()
 
- Public Member Functions inherited from AbstractGenerator
 __construct ($options=[])
 
 setSourceDirty ($isSourceDirty=true)
 
 isSourceDirty ()
 
 setIndentation ($indentation)
 
 getIndentation ()
 
 setSourceContent ($sourceContent)
 
 getSourceContent ()
 
 setOptions ($options)
 

Static Public Member Functions

static fromReflection (ClassReflection $classReflection)
 Build a Code Generation Php Object from a Class Reflection.
 
static fromArray (array $array)
 Generate from array.
 

Public Attributes

const OBJECT_TYPE = "class"
 
const IMPLEMENTS_KEYWORD = "implements"
 
const FLAG_ABSTRACT = 0x01
 
const FLAG_FINAL = 0x02
 
- Public Attributes inherited from AbstractGenerator
const LINE_FEED = "\n"
 Line feed to use in place of EOL.
 

Protected Attributes

 $containingFileGenerator = null
 
 $namespaceName = null
 
 $docBlock = null
 
 $name = null
 
 $flags = 0x00
 
 $extendedClass = null
 
 $implementedInterfaces = []
 
 $properties = []
 
 $constants = []
 
 $methods = []
 
 $traitUsageGenerator
 
- Protected Attributes inherited from AbstractGenerator
 $isSourceDirty = true
 
 $indentation = ' '
 
 $sourceContent = null
 

Constructor & Destructor Documentation

__construct (   $name = null,
  $namespaceName = null,
  $flags = null,
  $extends = null,
  $interfaces = [],
  $properties = [],
  $methods = [],
  $docBlock = null 
)
Parameters
string$name
string$namespaceName
array | string$flags
string$extends
array$interfaces
array$properties
array$methods
DocBlockGenerator$docBlock

Member Function Documentation

addConstant (   $name,
  $value 
)

Add Constant.

Parameters
string$namenon-empty string
string | int | null | float | array$valuescalar
Exceptions
Exception\InvalidArgumentException
Returns
ClassGenerator
addConstantFromGenerator ( PropertyGenerator  $constant)

Add constant from PropertyGenerator.

Parameters
PropertyGenerator$constant
Exceptions
Exception\InvalidArgumentException
Returns
ClassGenerator
addConstants ( array  $constants)
Parameters
PropertyGenerator[]|array[]$constants
Returns
ClassGenerator
addFlag (   $flag)
Parameters
string$flag
Returns
ClassGenerator
addMethod (   $name,
array  $parameters = [],
  $flags = MethodGenerator::FLAG_PUBLIC,
  $body = null,
  $docBlock = null 
)

Add Method from scalars.

Parameters
string$name
array$parameters
int$flags
string$body
string$docBlock
Exceptions
Exception\InvalidArgumentException
Returns
ClassGenerator
addMethodFromGenerator ( MethodGenerator  $method)

Add Method from MethodGenerator.

Parameters
MethodGenerator$method
Exceptions
Exception\InvalidArgumentException
Returns
ClassGenerator
addMethods ( array  $methods)
Parameters
array$methods
Returns
ClassGenerator
addProperties ( array  $properties)
Parameters
array$properties
Returns
ClassGenerator
addProperty (   $name,
  $defaultValue = null,
  $flags = PropertyGenerator::FLAG_PUBLIC 
)

Add Property from scalars.

Parameters
string$name
string | array$defaultValue
int$flags
Exceptions
Exception\InvalidArgumentException
Returns
ClassGenerator
addPropertyFromGenerator ( PropertyGenerator  $property)

Add property from PropertyGenerator.

Parameters
PropertyGenerator$property
Exceptions
Exception\InvalidArgumentException
Returns
ClassGenerator
addTrait (   $trait)
addTraitAlias (   $method,
  $alias,
  $visibility = null 
)
addTraitOverride (   $method,
  $traitsToReplace 
)
addTraits ( array  $traits)
addUse (   $use,
  $useAlias = null 
)

Add a class to "use" classes.

Parameters
string$use
string | null$useAlias
Returns
ClassGenerator
static fromArray ( array  $array)
static

Generate from array.

name string [required] Class Name filegenerator FileGenerator File generator that holds this class namespacename string The namespace for this class docblock string The docblock information flags int Flags, one of ClassGenerator::FLAG_ABSTRACT ClassGenerator::FLAG_FINAL extendedclass string Class which this class is extending implementedinterfaces properties methods

Exceptions
Exception\InvalidArgumentException
Parameters
array$array
Returns
ClassGenerator
static fromReflection ( ClassReflection  $classReflection)
static

Build a Code Generation Php Object from a Class Reflection.

Parameters
ClassReflection$classReflection
Returns
ClassGenerator
generate ( )

Implements GeneratorInterface.

getConstant (   $constantName)
Parameters
string$constantName
Returns
PropertyGenerator|false
getConstants ( )
Returns
PropertyGenerator[] indexed by constant name
getContainingFileGenerator ( )
Returns
FileGenerator
getDocBlock ( )
getExtendedClass ( )
Returns
string
getImplementedInterfaces ( )
Returns
array
getMethod (   $methodName)
Parameters
string$methodName
Returns
MethodGenerator|false
getMethods ( )
Returns
MethodGenerator[]
getName ( )
Returns
string
getNamespaceName ( )
Returns
string
getProperties ( )
getProperty (   $propertyName)
Parameters
string$propertyName
Returns
PropertyGenerator|false
getTraitAliases ( )
getTraitOverrides ( )
getTraits ( )
getUses ( )

Returns the "use" classes.

Returns
array
hasConstant (   $constantName)
Parameters
string$constantName
Returns
bool
hasMethod (   $methodName)
Parameters
string$methodName
Returns
bool
hasProperty (   $propertyName)
Parameters
string$propertyName
Returns
bool
hasTrait (   $traitName)
isAbstract ( )
Returns
bool
isFinal ( )
Returns
bool
isSourceDirty ( )
Returns
bool
removeFlag (   $flag)
Parameters
string$flag
Returns
ClassGenerator
removeMethod (   $methodName)
Parameters
string$methodName
Returns
ClassGenerator
removeTrait (   $traitName)
removeTraitOverride (   $method,
  $overridesToRemove = null 
)
setAbstract (   $isAbstract)
Parameters
bool$isAbstract
Returns
ClassGenerator
setContainingFileGenerator ( FileGenerator  $fileGenerator)
Parameters
FileGenerator$fileGenerator
Returns
ClassGenerator
setDocBlock ( DocBlockGenerator  $docBlock)
Parameters
DocBlockGenerator$docBlock
Returns
ClassGenerator
setExtendedClass (   $extendedClass)
Parameters
string$extendedClass
Returns
ClassGenerator
setFinal (   $isFinal)
Parameters
bool$isFinal
Returns
ClassGenerator
setFlags (   $flags)
Parameters
array | string$flags
Returns
ClassGenerator
setImplementedInterfaces ( array  $implementedInterfaces)
Parameters
array$implementedInterfaces
Returns
ClassGenerator
setName (   $name)
Parameters
string$name
Returns
ClassGenerator
setNamespaceName (   $namespaceName)
Parameters
string$namespaceName
Returns
ClassGenerator

Member Data Documentation

$constants = []
protected
$containingFileGenerator = null
protected
$docBlock = null
protected
$extendedClass = null
protected
$flags = 0x00
protected
$implementedInterfaces = []
protected
$methods = []
protected
$name = null
protected
$namespaceName = null
protected
$properties = []
protected
$traitUsageGenerator
protected
const FLAG_ABSTRACT = 0x01
const FLAG_FINAL = 0x02
const IMPLEMENTS_KEYWORD = "implements"
const OBJECT_TYPE = "class"