Documentation

TraitUsageGenerator extends AbstractGenerator
in package
implements TraitUsageInterface

Table of Contents

Interfaces

TraitUsageInterface

Constants

LINE_FEED  = "\n"
Line feed to use in place of EOL

Properties

$classGenerator  : ClassGenerator
$indentation  : string
$isSourceDirty  : bool
$sourceContent  : string|null
TODO: Type should be changed to "string" in the next major version. Nullable for BC
$traitAliases  : array<string|int, mixed>
$traitOverrides  : array<string|int, mixed>
$traits  : array<string|int, mixed>
$uses  : array<string|int, mixed>

Methods

__construct()  : mixed
addTrait()  : self
Add trait takes an array of trait options or string as arguments.
addTraitAlias()  : mixed
Add a trait alias. This will be used to generate the AS portion of the use statement.
addTraitOverride()  : mixed
Add a trait method override. This will be used to generate the INSTEADOF portion of the use statement.
addTraits()  : self
Add multiple traits. Trait can be an array of trait names or array of trait configurations
addUse()  : self
Add a class to "use" classes
generate()  : mixed
getIndentation()  : string
getSourceContent()  : string|null
getTraitAliases()  : array<string|int, mixed>
getTraitOverrides()  : array<string|int, mixed>
Return trait overrides
getTraits()  : array<string|int, mixed>
Get a list of trait names
getUseAlias()  : string|null
Returns the alias of the provided FQCN
getUses()  : array<string|int, mixed>
Returns the "use" classes
hasTrait()  : bool
Check to see if the class has a trait defined
hasUse()  : bool
hasUseAlias()  : bool
isSourceDirty()  : bool
isUseAlias()  : bool
Returns true if the alias is defined in the use list
removeTrait()  : mixed
Remove a trait by its name
removeTraitOverride()  : self
Remove an override for a given trait::method
removeUse()  : TraitUsageGenerator
removeUseAlias()  : TraitUsageGenerator
setIndentation()  : AbstractGenerator
setOptions()  : AbstractGenerator
setSourceContent()  : AbstractGenerator
setSourceDirty()  : AbstractGenerator

Constants

Properties

$sourceContent

TODO: Type should be changed to "string" in the next major version. Nullable for BC

protected string|null $sourceContent = null

$traitAliases

protected array<string|int, mixed> $traitAliases = []

Array of trait aliases

$traitOverrides

protected array<string|int, mixed> $traitOverrides = []

Array of trait overrides

$traits

protected array<string|int, mixed> $traits = []
Tags
psalm-var

array<int, string> Array of trait names

Methods

addTrait()

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

public addTrait(mixed $trait) : self
Parameters
$trait : mixed
Tags
inheritDoc
Return values
self

addTraitAlias()

Add a trait alias. This will be used to generate the AS portion of the use statement.

public addTraitAlias(mixed $method, mixed $alias[, mixed $visibility = null ]) : mixed
Parameters
$method : mixed

String or Array

$alias : mixed
$visibility : mixed = null
Tags
inheritDoc

addTraitOverride()

Add a trait method override. This will be used to generate the INSTEADOF portion of the use statement.

public addTraitOverride(mixed $method, mixed $traitsToReplace) : mixed
Parameters
$method : mixed
$traitsToReplace : mixed
Tags
inheritDoc

addTraits()

Add multiple traits. Trait can be an array of trait names or array of trait configurations

public addTraits(array<string|int, mixed> $traits) : self
Parameters
$traits : array<string|int, mixed>

Array of string names or configurations (@see addTrait)

Tags
inheritDoc
Return values
self

addUse()

Add a class to "use" classes

public addUse(mixed $use[, mixed $useAlias = null ]) : self
Parameters
$use : mixed
$useAlias : mixed = null
Tags
inheritDoc
Return values
self

getSourceContent()

public getSourceContent() : string|null
Return values
string|null

getTraitAliases()

public getTraitAliases() : array<string|int, mixed>
Tags
inheritDoc
Return values
array<string|int, mixed>

getTraitOverrides()

Return trait overrides

public getTraitOverrides() : array<string|int, mixed>
Tags
inheritDoc
Return values
array<string|int, mixed>

getTraits()

Get a list of trait names

public getTraits() : array<string|int, mixed>
Tags
inheritDoc
Return values
array<string|int, mixed>

getUseAlias()

Returns the alias of the provided FQCN

public getUseAlias(string $use) : string|null
Parameters
$use : string
Return values
string|null

getUses()

Returns the "use" classes

public getUses() : array<string|int, mixed>
Tags
inheritDoc
Return values
array<string|int, mixed>

hasTrait()

Check to see if the class has a trait defined

public hasTrait(mixed $traitName) : bool
Parameters
$traitName : mixed
Tags
inheritDoc
Return values
bool

hasUse()

public hasUse(string $use) : bool
Parameters
$use : string
Return values
bool

hasUseAlias()

public hasUseAlias(string $use) : bool
Parameters
$use : string
Return values
bool

isUseAlias()

Returns true if the alias is defined in the use list

public isUseAlias(string $alias) : bool
Parameters
$alias : string
Return values
bool

removeTrait()

Remove a trait by its name

public removeTrait(mixed $traitName) : mixed
Parameters
$traitName : mixed
Tags
inheritDoc

removeTraitOverride()

Remove an override for a given trait::method

public removeTraitOverride(mixed $method[, mixed $overridesToRemove = null ]) : self
Parameters
$method : mixed
$overridesToRemove : mixed = null
Tags
inheritDoc
Return values
self

        
On this page

Search results