ReflectionProperty::getHook
Returns a reflection object for a specified hook
説明
public ReflectionMethodnull ReflectionProperty::getHook(PropertyHookType $type
)
Gets the reflection of the property's hook, if any.
パラメータ
-
PropertyHookType
-
The type of hook to request.
戻り値
If the requested hook is defined, a ReflectionMethod instance will be returned.
If not, the method will return null
例
例1 ReflectionProperty::getHook example
<?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