ReflectionClassConstant::getAttributes
Verifica los atributos
&reftitle.description;
public arrayReflectionClassConstant::getAttributes
stringnullname&null;
intflags0
Verifica todos los atributos declarados en esta constante de clase en forma de un array de objetos ReflectionAttribute.
&reftitle.parameters;
&reflection.getattributes.param.name;
&reflection.getattributes.param.flags;
&reftitle.returnvalues;
Un array de atributos, en forma de objetos ReflectionAttribute.
&reftitle.examples;
Uso simple
getAttributes();
print_r(array_map(fn($attribute) => $attribute->getName(), $attributes));
?>
]]>
&example.outputs;
Fruit
[1] => Red
)
]]>
Resultados filtrados por nombre de clase
getAttributes('Fruit');
print_r(array_map(fn($attribute) => $attribute->getName(), $attributes));
?>
]]>
&example.outputs;
Fruit
)
]]>
Resultados filtrados por nombre de clase, con herencia
getAttributes('Color', ReflectionAttribute::IS_INSTANCEOF);
print_r(array_map(fn($attribute) => $attribute->getName(), $attributes));
?>
]]>
&example.outputs;
Red
)
]]>
&reftitle.seealso;
ReflectionClass::getAttributes
ReflectionFunctionAbstract::getAttributes
ReflectionParameter::getAttributes
ReflectionProperty::getAttributes