parent root
PHP: ReflectionProperty::getDeclaringClass - Manual

ReflectionProperty::getDeclaringClass

(PHP 5, PHP 7)

ReflectionProperty::getDeclaringClassGets declaring class

Description

public ReflectionProperty::getDeclaringClass ( void ) : ReflectionClass

Gets the declaring class.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

A ReflectionClass object.

See Also

add a noteadd a note

User Contributed Notes 1 note

up
4
metamarkers at gmail dot com
6 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.

<?php

class X {
   
}

$x = new X();
$x->foo = 'bar';
$reflection = new ReflectionObject($x);
echo
$reflection->getProperty('foo')->getDeclaringClass()->getName(); // X

?>
To Top
parent root