Skip to content

Commit 98d28ca

Browse files
committed
handle trait_exists in HeroAutoload
1 parent 64c647e commit 98d28ca

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/HeroAutoload.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,24 @@
88

99
class HeroAutoload
1010
{
11-
public static function handle(string $class)
11+
public static function handle(string $classOrTraitOrInterface)
1212
{
13-
if (\class_exists($class, false)) {
14-
return;
15-
}
16-
1713
$debugBacktrace = \debug_backtrace();
1814
if (
1915
isset($debugBacktrace[1]['function'], $debugBacktrace[2]['function']) &&
2016
$debugBacktrace[1]['function'] === 'spl_autoload_call' &&
2117
(
22-
$debugBacktrace[2]['function'] === 'class_exists' || $debugBacktrace[2]['function'] === 'interface_exists'
18+
$debugBacktrace[2]['function'] === 'class_exists' ||
19+
$debugBacktrace[2]['function'] === 'trait_exists' ||
20+
$debugBacktrace[2]['function'] === 'interface_exists'
2321
)
2422
) {
2523
return;
2624
}
2725

2826
throw new RuntimeException(sprintf(
29-
'class %s not found',
30-
$class
27+
'class or trait or interface %s not found',
28+
$classOrTraitOrInterface
3129
));
3230
}
3331
}

0 commit comments

Comments
 (0)