Documentation

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
category

Pop

author

Nick Sagona, III nick@popphp.org

copyright

Copyright (c) 2009-2026 Nick Sagona, III

license

https://www.popphp.org/license New BSD License

version
6.0.0

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 = []

$name

Name

protected string|null $name = null

Methods

__construct()

Constructor

public __construct(string $name) : mixed

Instantiate the attribute generator object

Parameters
$name : string

addArgument()

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
AttributeGenerator

getArguments()

Get the arguments

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

getName()

Get the name

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

getOutput()

Get the output

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

hasName()

Get the name

public hasName() : bool
Return values
bool

isRendered()

Is rendered (alias to hasOutput())

public isRendered() : bool
Return values
bool

printIndent()

Print the indent

public printIndent() : string
Return values
string

setName()

Set the name

public setName(string $name) : static
Parameters
$name : string
Return values
static

        
On this page

Search results