ReflectionProperty::getHook
PHP function
Edit on GitHub ✎
(PHP 8 >= 8.4.0)
Returns a reflection object for a specified hook
Description
ReflectionProperty::getHook(PropertyHookType $type): ReflectionMethod|null
Gets the reflection of the property's hook, if any.
Parameters
PropertyHookTypeThe type of hook to request.
Return Values
If the requested hook is defined, a ReflectionMethod instance will be returned. If not, the method will return null
Examples
ReflectionProperty::getHook example
php
<?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));
?>The above example will output:
output
object(ReflectionMethod)#4 (2) {
["name"]=>
string(10) "$name::get"
["class"]=>
string(7) "Example"
}
NULLSee Also
ReflectionMethodPropertyHookType