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