Skip to content

Commit

Permalink
fix autoloader
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Eichhorn committed Sep 25, 2023
1 parent aa20bdf commit 3bf96c3
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tests/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,25 @@ public static function addPath(string $path) : void
*/
public static function defaultAutoloader(string $class) : void
{
$class = \ltrim($class, '\\');
$class = \strtr($class, '_\\', '//');
$class = \ltrim($class, '\\');
$class = \strtr($class, '_\\', '//');
$class2 = $class;

$pos = \stripos($class, '/');
if ($pos !== false) {
$pos = \stripos($class, '/', $pos + 1);

if ($pos !== false) {
$class2 = \substr($class, $pos + 1);
}
}

foreach (self::$paths as $path) {
if (\is_file($file = $path . $class . '.php')) {
if (\is_file($file = $path . $class2 . '.php')) {
include_once $file;

return;
} elseif (\is_file($file = $path . $class . '.php')) {
include_once $file;

return;
Expand Down

0 comments on commit 3bf96c3

Please sign in to comment.