ReflectionProperty::hasHook

(PHP 8 >= 8.4.0)

ReflectionProperty::hasHookReturns whether the property has a given hook defined.

说明

public ReflectionProperty::hasHook(PropertyHookType $type): bool

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)

参见

添加备注

用户贡献的备注

此页面尚无用户贡献的备注。
To Top