Skip to content

Commit

Permalink
Redid the way the autoloader figures out what class was included due …
Browse files Browse the repository at this point in the history
…to differences between PHP proper and HHVM
  • Loading branch information
gsherwood committed Nov 26, 2015
1 parent dcfe851 commit 12bcb35
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,23 @@ public static function loadFile($path)

include $path;

$className = null;
$newClasses = array_diff(get_declared_classes(), $classes);
$className = array_pop($newClasses);
foreach ($newClasses as $name) {
if (isset(self::$loadedFiles[$name]) === false) {
$className = $name;
break;
}
}

if ($className === null) {
$newClasses = array_diff(get_declared_interfaces(), $classes);
$className = array_pop($newClasses);
foreach ($newClasses as $name) {
if (isset(self::$loadedFiles[$name]) === false) {
$className = $name;
break;
}
}
}

self::$loadedClasses[$path] = $className;
Expand Down

0 comments on commit 12bcb35

Please sign in to comment.