note 113785 added to reflectionclass.gettraitnames
| From: | emulienfou at gmail dot com | Date: | Sat, 30 Nov 2013 15:55:27 +0000 |
| Subject: | note 113785 added to reflectionclass.gettraitnames | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-197682@lists.php.net to get a copy of this message | ||
This remote return only the trait names from the current class.
If your class extends another class using your trait, you can't get the names. However, you can
do something like :
<?php
$traitsNames = [];
$recursiveClasses = function ($class) use(&$recursiveClasses, &$traitsNames) {
if ($class->getParentClass() != false) {
$recursiveClasses($class->getParentClass());
}
else {
$traitsNames = array_merge($traitsNames, $class->getTraitNames());
}
};
$recursiveClasses($controllerClass);
----
Server IP: 72.52.91.14
Probable Submitter: 72.52.91.14
----
Manual Page -- http://php.net/manual/en/reflectionclass.gettraitnames.php
Edit -- https://master.php.net/note/edit/113785
Del: integrated -- https://master.php.net/note/delete/113785/integrated
Del: useless -- https://master.php.net/note/delete/113785/useless
Del: bad code -- https://master.php.net/note/delete/113785/bad+code
Del: spam -- https://master.php.net/note/delete/113785/spam
Del: non-english -- https://master.php.net/note/delete/113785/non-english
Del: in docs -- https://master.php.net/note/delete/113785/in+docs
Del: other reasons-- https://master.php.net/note/delete/113785
Reject -- https://master.php.net/note/reject/113785
Search -- https://master.php.net/manage/user-notes.php