ReflectionProperty::getHook
指定したフックに対応するリフレクションオブジェクトを返す
説明
public ReflectionMethodnull ReflectionProperty::getHook(PropertyHookType $type)
プロパティフックが存在した場合、対応するリフレクションオブジェクトを返します。
パラメータ
-
PropertyHookType
-
プロパティフックのタイプ
戻り値
指定されたフックが定義されている場合、
ReflectionMethod のインスタンスを返します。
定義されていない場合、null を返します。
例
例1 ReflectionProperty::getHook の例
<?php
class Example
{
public string $name { get => "Name here"; }
}
$rClass = new \ReflectionClass(Example::class);
$rProp = $rClass->getProperty('name');
var_dump($rProp->getHook(PropertyHookType::Get));
var_dump($rProp->getHook(PropertyHookType::Set));
?>
object(ReflectionMethod)#4 (2) {
["name"]=>
string(10) "$name::get"
["class"]=>
string(7) "Example"
}
NULL
参考
- ReflectionMethod
- PropertyHookType