array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'tr', ), 'this' => array ( 0 => 'reflectionproperty.hashook.php', 1 => 'ReflectionProperty::hasHook', 2 => 'Returns whether the property has a given hook defined', ), 'up' => array ( 0 => 'class.reflectionproperty.php', 1 => 'ReflectionProperty', ), 'prev' => array ( 0 => 'reflectionproperty.hasdefaultvalue.php', 1 => 'ReflectionProperty::hasDefaultValue', ), 'next' => array ( 0 => 'reflectionproperty.hashooks.php', 1 => 'ReflectionProperty::hasHooks', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/reflection/reflectionproperty/hashook.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

ReflectionProperty::hasHook

(PHP 8 >= 8.4.0)

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

Açıklama

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

Returns whether the property has a given hook defined.

Bağımsız Değişkenler

PropertyHookType
The type of hook to check for.

Dönen Değerler

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

Örnekler

Örnek 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));
?>

Yukarıdaki örneğin çıktısı:

bool(true)
bool(false)

Ayrıca Bakınız