ReflectionFunctionAbstract::getAttributes アトリビュートを取得する &reftitle.description; public arrayReflectionFunctionAbstract::getAttributes stringnullname&null; intflags0 この関数で宣言されている全てのアトリビュートを、 ReflectionAttribute として返します。 &reftitle.parameters; &reflection.getattributes.param.name; &reflection.getattributes.param.flags; &reftitle.returnvalues; アトリビュートの配列を、 ReflectionAttribute オブジェクトの配列として返します。 &reftitle.examples; メソッドを使った、基本的な使い方 getAttributes(); print_r(array_map(fn($attribute) => $attribute->getName(), $attributes)); ?> ]]> &example.outputs; Fruit [1] => Red ) ]]> 関数を使った、基本的な使い方 getAttributes(); print_r(array_map(fn($attribute) => $attribute->getName(), $attributes)); ?> ]]> &example.outputs; Fruit [1] => Red ) ]]> クラス名を使って結果をフィルタする getAttributes('Fruit'); print_r(array_map(fn($attribute) => $attribute->getName(), $attributes)); ?> ]]> &example.outputs; Fruit ) ]]> クラス名、かつ継承も考慮して結果をフィルタする getAttributes('Color', ReflectionAttribute::IS_INSTANCEOF); print_r(array_map(fn($attribute) => $attribute->getName(), $attributes)); ?> ]]> &example.outputs; Red ) ]]> &reftitle.seealso; ReflectionClass::getAttributes ReflectionClassConstant::getAttributes ReflectionParameter::getAttributes ReflectionProperty::getAttributes