note 112671 added to function.class-uses

From: Date: Thu, 11 Jul 2013 09:21:13 +0000
Subject: note 112671 added to function.class-uses
Groups: php.notes 
Request: Send a blank email to php-notes+get-195571@lists.php.net to get a copy of this message
A slighly modified version from Stealz that also checks all the "parent" traits used by the traits: <?php public static function class_uses_deep($class, $autoload = true) { $traits = []; // Get traits of all parent classes do { $traits = array_merge(class_uses($class, $autoload), $traits); } while ($class = get_parent_class($class)); // Get traits of all parent traits $traitsToSearch = $traits; while (!empty($traitsToSearch)) { $newTraits = class_uses(array_pop($traitsToSearch), $autoload); $traits = array_merge($newTraits, $traits); $traitsToSearch = array_merge($newTraits, $traitsToSearch); }; foreach ($traits as $trait => $same) { $traits = array_merge(class_uses($trait, $autoload), $traits); } return array_unique($traits); } ?> ---- Server IP: 69.147.83.199 Probable Submitter: 85.183.23.96 ---- Manual Page -- http://php.net/manual/en/function.class-uses.php Edit -- https://master.php.net/note/edit/112671 Del: integrated -- https://master.php.net/note/delete/112671/integrated Del: useless -- https://master.php.net/note/delete/112671/useless Del: bad code -- https://master.php.net/note/delete/112671/bad+code Del: spam -- https://master.php.net/note/delete/112671/spam Del: non-english -- https://master.php.net/note/delete/112671/non-english Del: in docs -- https://master.php.net/note/delete/112671/in+docs Del: other reasons-- https://master.php.net/note/delete/112671 Reject -- https://master.php.net/note/reject/112671 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#195571) next »