I have an PHP attribute as follow:
#[Attribute(Attribute::TARGET_PROPERTY|Attribute::TARGET_METHOD|Attribute::TARGET_PARAMETER)]
class NotNull implements Constraint{
...
}
Now, I want to get the list of all attributes of a property and check if they are instance of Constraint:
$propertyReflection = ...;
$attributes = $propertyReflection->getAttributes();
foreach($attributes as $attribute){
if($attribute instanceof Constraint){
// do something
}
}
However, it do nothing?
So, my question is: is it possible to implement an interface with an attribute and then check if the attribute is an instance?
Aucun commentaire:
Enregistrer un commentaire