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 64c647e commit 98d28ca
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/HeroAutoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,24 @@

class HeroAutoload
{
public static function handle(string $class)
public static function handle(string $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 98d28ca

Please sign in to comment.