AttributeGenerator
extends AbstractGenerator
in package
uses
NameTrait
Attribute generator class
Represents one #[Name(args)] usage. Deliberately never calls printIndent() — its correct
indentation depends entirely on where it's used (none for a class-level attribute, matching the
host's own indent for a member-level one), a decision made by the caller (AttributesTrait), not by
this class.
Tags
Table of Contents
Properties
- $arguments : array<string|int, mixed>
- Arguments, each shaped ['name' => ?string, 'value' => mixed]
- $indent : int
- Code indent spaces
- $name : string|null
- Name
- $output : string|null
- Output string
Methods
- __construct() : mixed
- Constructor
- __toString() : string
- Print attribute
- addArgument() : AttributeGenerator
- Add an argument
- getArguments() : array<string|int, mixed>
- Get the arguments
- getIndent() : int
- Get the indent
- getName() : string|null
- Get the name
- getOutput() : string|null
- Get the output
- hasArguments() : bool
- Has arguments
- hasIndent() : bool
- Has indent
- hasName() : bool
- Get the name
- hasOutput() : bool
- Has output
- isRendered() : bool
- Is rendered (alias to hasOutput())
- printIndent() : string
- Print the indent
- render() : string
- Render attribute
- setIndent() : AbstractGenerator
- Set the indent
- setName() : static
- Set the name
Properties
$arguments
Arguments, each shaped ['name' => ?string, 'value' => mixed]
protected
array<string|int, mixed>
$arguments
= []
$indent
Code indent spaces
protected
int
$indent
= 4
$name
Name
protected
string|null
$name
= null
$output
Output string
protected
string|null
$output
= null
Methods
__construct()
Constructor
public
__construct(string $name) : mixed
Instantiate the attribute generator object
Parameters
- $name : string
__toString()
Print attribute
public
__toString() : string
Return values
stringaddArgument()
Add an argument
public
addArgument(mixed $value[, string|null $name = null ]) : AttributeGenerator
Parameter order is (value, name), not (name, value) like Traits\FunctionTrait::addArgument() elsewhere in this library — deliberate, since it mirrors ReflectionAttribute::getArguments()'s own shape (numeric keys positional, string keys named) and makes the common positional case a single-argument call: addArgument('value') rather than addArgument(null, 'value').
Parameters
- $value : mixed
- $name : string|null = null
Return values
AttributeGeneratorgetArguments()
Get the arguments
public
getArguments() : array<string|int, mixed>
Return values
array<string|int, mixed>getIndent()
Get the indent
public
getIndent() : int
Return values
intgetName()
Get the name
public
getName() : string|null
Return values
string|nullgetOutput()
Get the output
public
getOutput() : string|null
Return values
string|nullhasArguments()
Has arguments
public
hasArguments() : bool
Return values
boolhasIndent()
Has indent
public
hasIndent() : bool
Return values
boolhasName()
Get the name
public
hasName() : bool
Return values
boolhasOutput()
Has output
public
hasOutput() : bool
Return values
boolisRendered()
Is rendered (alias to hasOutput())
public
isRendered() : bool
Return values
boolprintIndent()
Print the indent
public
printIndent() : string
Return values
stringrender()
Render attribute
public
render() : string
Return values
stringsetIndent()
Set the indent
public
setIndent(int $indent) : AbstractGenerator
Parameters
- $indent : int
Return values
AbstractGeneratorsetName()
Set the name
public
setName(string $name) : static
Parameters
- $name : string