Skip to content

Commit 95644fb

Browse files
committed
feat: add global function does_trait_use
1 parent 6a1a495 commit 95644fb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Global/base.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,19 @@ function trait_uses_recursive(string $trait): array
133133
}
134134
}
135135

136+
if (!function_exists('does_trait_use')) {
137+
/**
138+
* @param string $class
139+
* @param string $trait
140+
*
141+
* @return bool
142+
*/
143+
function does_trait_use(string $class, string $trait): bool
144+
{
145+
return isset(trait_uses_recursive($class)[$trait]);
146+
}
147+
}
148+
136149
if (!function_exists('class_uses_recursive')) {
137150
/**
138151
* Returns all traits used by a class, its parent classes and trait of their traits.

0 commit comments

Comments
 (0)