note 110752 added to function.class-uses
| From: | stealz at op dot pl | Date: | Sat, 01 Dec 2012 10:21:01 +0000 |
| Subject: | note 110752 added to function.class-uses | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-192243@lists.php.net to get a copy of this message | ||
To get ALL traits including those used by parent classes and other traits, use this function:
function class_uses_deep($class, $autoload = true) {
$traits = [];
do {
$traits = array_merge(class_uses($class, $autoload), $traits);
} while($class = get_parent_class($class));
foreach ($traits as $trait => $same) {
$traits = array_merge(class_uses($trait, $autoload), $traits);
}
return array_unique($traits);
}
----
Server IP: 46.17.113.3
Probable Submitter: 193.34.52.245
----
Manual Page -- http://www.php.net/manual/en/function.class-uses.php
Edit -- https://master.php.net/note/edit/110752
Del: integrated -- https://master.php.net/note/delete/110752/integrated
Del: useless -- https://master.php.net/note/delete/110752/useless
Del: bad code -- https://master.php.net/note/delete/110752/bad+code
Del: spam -- https://master.php.net/note/delete/110752/spam
Del: non-english -- https://master.php.net/note/delete/110752/non-english
Del: in docs -- https://master.php.net/note/delete/110752/in+docs
Del: other reasons-- https://master.php.net/note/delete/110752
Reject -- https://master.php.net/note/reject/110752
Search -- https://master.php.net/manage/user-notes.php