Documentation

TraitUsageInterface

Table of Contents

Methods

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
getTraitAliases()  : array<string|int, mixed>
getTraitOverrides()  : array<string|int, mixed>
Return trait overrides
getTraits()  : array<string|int, mixed>
Get a list of trait names
getUses()  : array<string|int, mixed>
Returns the "use" classes
hasTrait()  : bool
Check to see if the class has a trait defined
removeTrait()  : mixed
Remove a trait by its name
removeTraitOverride()  : self
Remove an override for a given trait::method

Methods

addTrait()

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

public addTrait(string|array<string|int, mixed> $trait) : 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 : string|array<string|int, mixed>
Tags
psalm-param

string|array{traitName: string, aliases?: array, insteadof?: array} $trait

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, string $alias[, null|int $visibility = null ]) : mixed

$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 : null|int = null

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

$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 : mixed

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
psalm-param

list<string|array{traitName: string, aliases?: array, insteadof?: array}> $traits

Return values
self

addUse()

Add a class to "use" classes

public addUse(string $use[, string|null $useAlias = null ]) : self
Parameters
$use : string
$useAlias : string|null = null
Return values
self

getTraitAliases()

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

getTraitOverrides()

Return trait overrides

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

getTraits()

Get a list of trait names

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

getUses()

Returns the "use" classes

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

hasTrait()

Check to see if the class has a trait defined

public hasTrait(string $traitName) : bool
Parameters
$traitName : string
Return values
bool

removeTrait()

Remove a trait by its name

public removeTrait(string $traitName) : mixed
Parameters
$traitName : string

removeTraitOverride()

Remove an override for a given trait::method

public removeTraitOverride(mixed $method[, mixed $overridesToRemove = null ]) : self

$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 : mixed
$overridesToRemove : mixed = null
Return values
self

        
On this page

Search results