Class AttributeInfo
Represents complete information about a discovered attribute.
This value object contains all metadata about an attribute found during scanning, including:
- The class and file where it was found
- The attribute class name and arguments
- Where it's attached (via AttributeTarget)
- Plugin context and file modification time for cache validation
This class is readonly and immutable for safe serialization and caching.
Method Summary
-
__construct() public
Constructor for AttributeInfo.
-
fromArray() public static
Create from array data.
-
getInstance() public
Instantiate the actual attribute object.
Returns the attribute instance with its arguments applied, allowing access to attribute properties and methods.
-
isInstanceOf() public
Check if the attribute is an instance of a given class.
Uses is_a() with allow_string to check inheritance without instantiation.
-
jsonSerialize() public
Specify data which should be serialized to JSON.
-
toArray() public
Convert to array for serialization.
Method Detail
__construct() ¶ public
__construct(string $className, string $attributeName, array<string, mixed> $arguments, string $filePath, int $lineNumber, Cake\AttributeResolver\ValueObject\AttributeTarget $target, int $fileTime = 0, string|null $pluginName = null)
Constructor for AttributeInfo.
Parameters
-
string$className Fully qualified class name containing the attribute
-
string$attributeName Fully qualified attribute class name
-
array<string, mixed>$arguments Attribute constructor arguments
-
string$filePath Absolute path to file where attribute was found
-
int$lineNumber Line number where attribute appears in file
-
Cake\AttributeResolver\ValueObject\AttributeTarget$target Target information (what the attribute is attached to)
-
int$fileTime optional File modification time (Unix timestamp) for cache validation
-
string|null$pluginName optional Plugin name or null for App namespace
fromArray() ¶ public static
fromArray(array<string, mixed> $data): self
Create from array data.
Parameters
-
array<string, mixed>$data Data array
Returns
selfgetInstance() ¶ public
getInstance(class-string<T>|null $expectedClass = null): T|object
Instantiate the actual attribute object.
Returns the attribute instance with its arguments applied, allowing access to attribute properties and methods.
Templates
T
of object Parameters
-
class-string<T>|null$expectedClass optional Optional expected class for type safety
Returns
T|objectThe instantiated attribute (T if expectedClass provided, otherwise object)
Throws
RuntimeExceptionIf the attribute class does not exist
InvalidArgumentExceptionIf attribute doesn't match expected class
isInstanceOf() ¶ public
isInstanceOf(class-string $className): bool
Check if the attribute is an instance of a given class.
Uses is_a() with allow_string to check inheritance without instantiation.
Parameters
-
class-string$className Class name to check against
Returns
boolTrue if the attribute extends or implements the given class
jsonSerialize() ¶ public
jsonSerialize(): array<string, mixed>
Specify data which should be serialized to JSON.
Returns
array<string, mixed>toArray() ¶ public
toArray(): array<string, mixed>
Convert to array for serialization.
Returns
array<string, mixed>