Class AttributeTarget
Represents information about where an attribute is attached.
This value object encapsulates the target of an attribute, including:
- The type of target (class, method, property, etc.)
- The name of the target
- The declaring class (if applicable)
- The declaring class kind (class, interface, trait, enum)
- Whether the declaring class is abstract
- Method visibility (for method-related targets)
This class is readonly and immutable for safe serialization.
Method Summary
-
__construct() public
Constructor for AttributeTarget.
-
fromArray() public static
Create from array data.
-
isInstantiableDeclaringType() public
Check whether the declaring type can be instantiated as a concrete class.
-
isPublicMethodTarget() public
Check whether the target is a public method target.
-
jsonSerialize() public
Specify data which should be serialized to JSON.
-
toArray() public
Convert to array for serialization.
Method Detail
__construct() ¶ public
__construct(Cake\AttributeResolver\Enum\AttributeTargetType $type, string $name, string|null $declaringClass = null, bool $isDeclaringClassAbstract = false, Cake\AttributeResolver\Enum\DeclaringClassType $declaringClassType = DeclaringClassType::CLASS_, Cake\AttributeResolver\Enum\MethodVisibility|null $methodVisibility = null)
Constructor for AttributeTarget.
Parameters
-
Cake\AttributeResolver\Enum\AttributeTargetType$type Target type
-
string$name Target name (e.g., method name, property name)
-
string|null$declaringClass optional Class name that declares this target
-
bool$isDeclaringClassAbstract optional Whether the declaring class is abstract
-
Cake\AttributeResolver\Enum\DeclaringClassType$declaringClassType optional Declaring class kind
-
Cake\AttributeResolver\Enum\MethodVisibility|null$methodVisibility optional Method visibility
fromArray() ¶ public static
fromArray(array<string, mixed> $data): self
Create from array data.
Parameters
-
array<string, mixed>$data Data array
Returns
selfisInstantiableDeclaringType() ¶ public
isInstantiableDeclaringType(): bool
Check whether the declaring type can be instantiated as a concrete class.
Returns
boolisPublicMethodTarget() ¶ public
isPublicMethodTarget(): bool
Check whether the target is a public method target.
Returns
booljsonSerialize() ¶ 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>