ReflectionProperty::getDeclaringClass

(PHP 5)

ReflectionProperty::getDeclaringClassGets declaring class

說明

public ReflectionClass ReflectionProperty::getDeclaringClass ( void )

Gets the declaring class.

Warning

此函式目前沒有參考文件;只有引數列表。

參數

此函式沒有參數。

回傳值

A ReflectionClass object.

參見

add a note add a note

User Contributed Notes 1 note

up
5
metamarkers at gmail dot com
10 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