« ReflectionProperty::getName
ReflectionProperty::getSettableType »

ReflectionProperty::getRawValue

(PHP 8 >= 8.4.0)

ReflectionProperty::getRawValue — get フックが定義されていたとしても、それを迂回してプロパティの値を返す

説明

public function ReflectionProperty::getRawValue(object $object): mixed
警告

この関数は、 現在のところ詳細な情報はありません。引数のリストのみが 記述されています。

get フックが定義されていたとしても、それを迂回してプロパティの値を返します。

パラメータ

object

値を取得するオブジェクト

戻り値

プロパティに保存した値を返します。 その値は get フックが定義されていたとしても、 それを迂回したものになります。

エラー / 例外

プロパティが仮想プロパティだった場合、 Error がスローされます。 取得する実体の値が存在しないためです。

例

例1 ReflectionProperty::getRawValue() の例

<?php

class Example
{
    public string $tag {
        get => strtolower($this->tag);
    }
}

$example = new Example();
$example->tag = 'PHP';

$rClass = new \ReflectionClass(Example::class);
$rProp = $rClass->getProperty('tag');

// getフックを経由した値なので、"php" を出力します。
echo $example->tag, PHP_EOL;
echo $rProp->getValue($example), PHP_EOL;

// フックを迂回するので、"PHP" を出力します。
echo $rProp->getRawValue($example);

?>

上の例の出力は以下となります。

php
php
PHP
関連キーワード:
プロパティ   フック   ReflectionProperty   迂回   getRawValue   example   Example   rProp   rClass   getName   getSettableType   mixed   詳細   記述   仮想   実体   strtolower   ReflectionClass   getProperty   経由   getValue   参考   非対称   可視
関連する関数・ページ:
reflectionproperty.setrawvalue   reflectionproperty.gethooks   reflectionproperty.getsettabletype   reflectionproperty.hashooks   reflectionproperty.getname   reflectionproperty.hashook