Methods

Add trait takes an array of trait options or string as arguments.

addTrait(mixed $trait) : \Zend\Code\Generator\self

Array Format: key: traitName value: String

key: aliases value: array of arrays key: method value: @see addTraitAlias key: alias value: @see addTraitAlias key: visibility value: @see addTraitAlias

key: insteadof value: array of arrays key: method value: @see self::addTraitOverride key: traitToReplace value: @see self::addTraitOverride

Parameters

$trait

mixed

String | Array

Returns

\Zend\Code\Generator\self

Add a trait alias.

addTraitAlias(mixed $method, string $alias, $visibility) 

This will be used to generate the AS portion of the use statement.

$method: This method provides 2 ways for defining the trait method. Option 1: String Option 2: Array key: traitName value: name of trait key: method value: trait method

$alias: Alias is a string representing the new method name.

$visibilty: ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PRIVATE| ReflectionMethod::IS_PROTECTED

Parameters

$method

mixed

String or Array

$alias

string

$visibility

Add a trait method override.

addTraitOverride(mixed $method, $traitsToReplace) 

This will be used to generate the INSTEADOF portion of the use statement.

$method: This method provides 2 ways for defining the trait method. Option 1: String Format: :: Option 2: Array key: traitName value: trait name key: method value: method name

$traitToReplace: The name of the trait that you wish to supersede.

This method provides 2 ways for defining the trait method. Option 1: String of trait to replace Option 2: Array of strings of traits to replace

Parameters

$method

mixed

$traitsToReplace

Add multiple traits.

addTraits(array $traits) : \Zend\Code\Generator\self

Trait can be an array of trait names or array of trait configurations

Parameters

$traits

Returns

\Zend\Code\Generator\self

Add a class to "use" classes

addUse(string $use, string | null $useAlias) : \Zend\Code\Generator\self

Parameters

$use

string

$useAlias

stringnull

Returns

\Zend\Code\Generator\self

getTraitAliases()

getTraitAliases() : array

Returns

array

Return trait overrides

getTraitOverrides() : array

Returns

array

Get a list of trait names

getTraits() : array

Returns

array

Returns the "use" classes

getUses() : array

Returns

array

Check to see if the class has a trait defined

hasTrait(\Zend\Code\Generator\strint $traitName) : bool

Parameters

$traitName

\Zend\Code\Generator\strint

Returns

bool

Remove a trait by its name

removeTrait($traitName) 

Parameters

$traitName

Remove an override for a given trait::method

removeTraitOverride($method, null $overridesToRemove) : \Zend\Code\Generator\$this

$method: This method provides 2 ways for defining the trait method. Option 1: String Format: :: Option 2: Array key: traitName value: trait name key: method value: method name

$overridesToRemove: The name of the trait that you wish to remove.

This method provides 2 ways for defining the trait method. Option 1: String of trait to replace Option 2: Array of strings of traits to replace

Parameters

$method

$overridesToRemove

null

Returns

\Zend\Code\Generator\$this