ReflectionProperty::getDeclaringClass
(PHP 5, PHP 7, PHP 8)
ReflectionProperty::getDeclaringClass — Gets declaring class
参数
此函数没有参数。
返回值
A ReflectionClass object.
+添加备注
用户贡献的备注 1 note
metamarkers at gmail dot com ¶
11 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
?>
备份地址:http://www.lvesu.com/blog/php/reflectionproperty.getdeclaringclass.php