PHP Conference Fukuoka 2025

ReflectionProperty::getDeclaringClass

(PHP 5, PHP 7, PHP 8)

ReflectionProperty::getDeclaringClassObtiene la clase declarante

Descripción

public ReflectionProperty::getDeclaringClass(): ReflectionClass

Obtiene la clase declarante.

Parámetros

Esta función no contiene ningún parámetro.

Valores devueltos

Un objeto ReflectionClass.

Ver también

add a note

User Contributed Notes 1 note

up
7
metamarkers at gmail dot com
12 years ago
If you're reflecting an object and get the declaring class of a property that's set but wasn't declared in any class, it returns the class of the instance.<?phpclass X {    }$x = new X();$x->foo = 'bar';$reflection = new ReflectionObject($x);echo $reflection->getProperty('foo')->getDeclaringClass()->getName(); // X?>
To Top