ReflectionProperty::hasHook

Returns whether the property has a given hook defined

説明

public bool ReflectionProperty::hasHook(PropertyHookType $type)

Returns whether the property has a given hook defined.

パラメータ

PropertyHookType
The type of hook to check for.

戻り値

Returns true if the hook is defined on this property, false if not.

例1 ReflectionProperty::hasHook example

<?php
class Example
{
    public string $name { get => "Name here"; }
}

$rClass = new \ReflectionClass(Example::class);
$rProp = $rClass->getProperty('name');
var_dump($rProp->hasHook(PropertyHookType::Get));
var_dump($rProp->hasHook(PropertyHookType::Set));
?>

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

bool(true)
bool(false)

参考

  • ReflectionMethod
  • PropertyHookType