ReflectionProperty::getHooks

(PHP 8 >= 8.4.0)

ReflectionProperty::getHooksDevuelve un array de todos los hooks en esta propiedad

Descripción

public ReflectionProperty::getHooks(): array

Devuelve una lista de todos los hooks en esta propiedad.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

Un array de objetos ReflectionMethod indexados por el hook al que corresponden. Por ejemplo, una propiedad con hooks get y set devolverá un array de 2 elementos con claves de string get y set, cada una es un objeto ReflectionMethod. El orden en que se devuelven es explícitamente indefinido. Si no hay hooks definidos, se devuelve un array vacío.

Ejemplos

Ejemplo #1 Ejemplo de ReflectionProperty::getHooks()

<?php
class Example
{
public
string $name { get => "Name here"; }

public
int $count;
}

$rClass = new \ReflectionClass(Example::class);

$rProp = $rClass->getProperty('name');
var_dump($rProp->getHooks());

$rProp = $rClass->getProperty('count');
var_dump($rProp->getHooks());
?>

El resultado del ejemplo sería:

array(1) {
  ["get"]=>
  object(ReflectionMethod)#3 (2) {
    ["name"]=>
    string(10) "$name::get"
    ["class"]=>
    string(7) "Example"
  }
}
array(0) {
}

Ver también

add a note

User Contributed Notes

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