diff --git a/src/Services/ClassUses.php b/src/Services/ClassUses.php new file mode 100644 index 00000000..eb9cc625 --- /dev/null +++ b/src/Services/ClassUses.php @@ -0,0 +1,70 @@ + $class] as $class) { + $results += self::traitUsesRecursive($class); + } + + return array_unique($results); + } + + /** + * Returns all traits used by a trait and its traits. + * + * @param string $trait + * @return array + */ + public static function traitUsesRecursive($trait) + { + $traits = class_uses($trait); + + foreach ($traits as $trait) { + $traits += self::traitUsesRecursive($trait); + } + + return $traits; + } +} diff --git a/src/Services/QueueMonitor.php b/src/Services/QueueMonitor.php index 7fea476b..e1094fda 100644 --- a/src/Services/QueueMonitor.php +++ b/src/Services/QueueMonitor.php @@ -166,7 +166,7 @@ protected static function jobFinished(JobContract $job, bool $failed = false, $e */ public static function shouldBeMonitored(JobContract $job): bool { - return array_key_exists(IsMonitored::class, class_uses_recursive( + return array_key_exists(IsMonitored::class, ClassUses::classUsesRecursive( $job->resolveName() )); }