diff --git a/src/Illuminate/Support/helpers.php b/src/Illuminate/Support/helpers.php index f1275739877e1e04e1a9adce65f46309b5e124a8..c79809c0ea09b2fdc7df29acd73ca1ef9bd11b17 100644 --- a/src/Illuminate/Support/helpers.php +++ b/src/Illuminate/Support/helpers.php @@ -106,15 +106,16 @@ function class_uses_recursive($class, bool $cache = false) if (is_object($class)) { $class = get_class($class); } - + $results = []; - + foreach (array_reverse(class_parents($class) ?: []) + [$class => $class] as $class) { $results += trait_uses_recursive($class, $cache); } - + return array_unique($results); }; + return $cache ? once($callback) : call_user_func($callback); } } @@ -473,6 +474,7 @@ function trait_uses_recursive($trait, bool $cache = false) return $traits; }; + return $cache ? once($callback) : call_user_func($callback); } }