Skip to content

Commit

Permalink
handle trait_exists in HeroAutoload
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Sep 17, 2018
1 parent 03dc082 commit 7f69f56
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/HeroAutoload.php
Expand Up @@ -6,26 +6,24 @@

class HeroAutoload
{
public static function handle($class)
public static function handle($classOrTraitOrInterface)
{
if (\class_exists($class, false)) {
return;
}

$debugBacktrace = \debug_backtrace();
if (
isset($debugBacktrace[1]['function'], $debugBacktrace[2]['function']) &&
$debugBacktrace[1]['function'] === 'spl_autoload_call' &&
(
$debugBacktrace[2]['function'] === 'class_exists' || $debugBacktrace[2]['function'] === 'interface_exists'
$debugBacktrace[2]['function'] === 'class_exists' ||
$debugBacktrace[2]['function'] === 'trait_exists' ||
$debugBacktrace[2]['function'] === 'interface_exists'
)
) {
return;
}

throw new RuntimeException(sprintf(
'class %s not found',
$class
'class or trait or interface %s not found',
$classOrTraitOrInterface
));
}
}

0 comments on commit 7f69f56

Please sign in to comment.