array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'it', ), '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

Descrizione

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

Returns whether the property has a given hook defined.

Elenco dei parametri

PropertyHookType
The type of hook to check for.

Valori restituiti

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

Esempi

Example #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));
?>

Il precedente esempio visualizzerĂ :

bool(true)
bool(false)

Vedere anche: