ReflectionProperty::getValue 値を取得する &reftitle.description; public mixedReflectionProperty::getValue objectnullobject&null; プロパティの値を取得します。 &reftitle.parameters; object static でないプロパティの場合は、プロパティを取得したいオブジェクトを指定しなければなりません。 オブジェクトを指定せずにデフォルトのプロパティを取得したい場合は、かわりに ReflectionClass::getDefaultProperties を使います。 &reftitle.returnvalues; プロパティの現在の値を返します。 &reftitle.changelog; &Version; &Description; 8.1.0 private と protected なプロパティは ReflectionProperty::getValue ですぐにアクセスできるようになりました。 これより前のバージョンでは、 ReflectionProperty::setAccessible をコールすることでアクセスできるようにする必要がありました。 そうしない場合、 ReflectionException がスローされていました。 8.0.0 object は、nullable になりました。 &reftitle.examples; <methodname>ReflectionProperty::getValue</methodname> の例 getProperty('staticProperty')->getValue()); var_dump($reflectionClass->getProperty('property')->getValue(new Foo)); $reflectionProperty = $reflectionClass->getProperty('privateProperty'); $reflectionProperty->setAccessible(true); // PHP 8.1.0 より前のバージョンのみ、この行の実行が必須でした var_dump($reflectionProperty->getValue(new Foo)); ?> ]]> &example.outputs; &reftitle.seealso; ReflectionProperty::setValue ReflectionProperty::setAccessible ReflectionClass::getDefaultProperties ReflectionClass::getStaticPropertyValue