ArrayOf
extends ObjAttribute
in package
Attribute specifying the element type of an array property.
Array-typed properties on Obj have no inherent element type, so #[ArrayOf] tells __unserialize() what class to instantiate (and call parse() on) for each element of the incoming array.
Usage:
class Order extends Obj {
#[ArrayOf(LineItem::class)]
public array $items;
}
Tags
Attributes
- #[Attribute]
- \Attribute::TARGET_PROPERTY
Table of Contents
Properties
- $innerType : string
Methods
- __construct() : mixed
- Initialize the array element type attribute.
- of() : static|false
- Extract an attribute instance from a reflected property.
Properties
$innerType
public
string
$innerType
Methods
__construct()
Initialize the array element type attribute.
public
__construct(string $innerType) : mixed
Parameters
- $innerType : string
-
Fully-qualified class name of the array elements.
of()
Extract an attribute instance from a reflected property.
public
static of(ReflectionProperty $field) : static|false
Searches the property's attributes for one matching this class name and instantiates it with the attribute's arguments.
Parameters
- $field : ReflectionProperty
-
The property to inspect for attributes.
Return values
static|false —The attribute instance if found, false otherwise.