Documentation

AttributesTrait

Attributes trait

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

$attributes  : array<string|int, mixed>
Attributes. An indexed list, not keyed by name — attributes can legitimately repeat (Attribute::IS_REPEATABLE), so a name-keyed map would silently collapse repeats.

Methods

addAttribute()  : static
Add an attribute
addAttributes()  : static
Add attributes
getAttributes()  : array<string|int, mixed>
Get all attributes
getAttributesByName()  : array<string|int, mixed>
Get all attributes with the given name (supports repeated attributes)
hasAttribute()  : bool
Has an attribute with the given name
hasAttributes()  : bool
Has attributes
removeAttribute()  : static
Remove an attribute (by instance identity — there is no unique name to remove by)
formatAttributes()  : string
Format the attributes

Properties

$attributes

Attributes. An indexed list, not keyed by name — attributes can legitimately repeat (Attribute::IS_REPEATABLE), so a name-keyed map would silently collapse repeats.

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

Methods

addAttributes()

Add attributes

public addAttributes(array<string|int, mixed> $attributes) : static
Parameters
$attributes : array<string|int, mixed>
Return values
static

getAttributes()

Get all attributes

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

getAttributesByName()

Get all attributes with the given name (supports repeated attributes)

public getAttributesByName(string $name) : array<string|int, mixed>
Parameters
$name : string
Return values
array<string|int, mixed>

hasAttribute()

Has an attribute with the given name

public hasAttribute(string $name) : bool
Parameters
$name : string
Return values
bool

hasAttributes()

Has attributes

public hasAttributes() : bool
Return values
bool

formatAttributes()

Format the attributes

protected formatAttributes([bool $indented = true ]) : string
Parameters
$indented : bool = true
Return values
string

        
On this page

Search results