ReflectionProperty::hasHook

(PHP 8 >= 8.4.0)

ReflectionProperty::hasHookIndica si la propiedad tiene un hook dado definido

Descripción

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

Indica si la propiedad tiene un hook dado definido.

Parámetros

PropertyHookType
El tipo de hook a verificar.

Valores devueltos

Devuelve true si el hook está definido en esta propiedad, de lo contrario false.

Ejemplos

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

El resultado del ejemplo sería:

bool(true)
bool(false)
add a note

User Contributed Notes

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