| Newsgroups |
php.notes |
| Message-ID |
<[email protected]> |
Be careful when use getDeclaringClass() for properties from traits
<?php
trait Y {
public $y;
}
class X {
use Y;
}
$x = new X();
$x->y = 42;
$reflection = new ReflectionObject($x);
echo $reflection->getProperty('y')->getDeclaringClass()->getName(); // X
?>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 109.71.244.180)
----
Manual Page -- https://php.net/manual/en/reflectionproperty.getdeclaringclass.php
Edit -- https://main.php.net/note/edit/130251
Del: integrated -- https://main.php.net/note/delete/130251/integrated
Del: useless -- https://main.php.net/note/delete/130251/useless
Del: bad code -- https://main.php.net/note/delete/130251/bad+code
Del: spam -- https://main.php.net/note/delete/130251/spam
Del: non-english -- https://main.php.net/note/delete/130251/non-english
Del: in docs -- https://main.php.net/note/delete/130251/in+docs
Del: other reasons-- https://main.php.net/note/delete/130251
Reject -- https://main.php.net/note/reject/130251
Search -- https://main.php.net/manage/user-notes.php