ReflectionProperty::hasHook

(PHP 8 >= 8.4.0)

ReflectionProperty::hasHookRenvoie si la propriété a un hook donné défini

Description

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

Renvoie si la propriété a un hook donné défini.

Liste de paramètres

PropertyHookType
Le type du hook à vérifier.

Valeurs de retour

Renvoie true si le hook est défini sur cette propriété, sinon false.

Exemples

Exemple #1 Exemple de ReflectionProperty::hasHook()

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

L'exemple ci-dessus va afficher :

bool(true)
bool(false)
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top