Skip to content

Commit

Permalink
[ClassLoader] Use only forward slashes in generated class map
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas authored and fabpot committed Nov 29, 2016
1 parent ec937cb commit 6d1f1b5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Symfony/Component/ClassLoader/ClassCollectionLoader.php
Expand Up @@ -63,7 +63,7 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =
throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s"', $cacheDir));
}
$cacheDir = rtrim(realpath($cacheDir) ?: $cacheDir, '/'.DIRECTORY_SEPARATOR);
$cache = $cacheDir.DIRECTORY_SEPARATOR.$name.$extension;
$cache = $cacheDir.'/'.$name.$extension;

// auto-reload
$reload = false;
Expand Down Expand Up @@ -114,7 +114,7 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =
REGEX;
$dontInlineRegex = str_replace('.', $spacesRegex, $dontInlineRegex);

$cacheDir = explode(DIRECTORY_SEPARATOR, $cacheDir);
$cacheDir = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $cacheDir));
$files = array();
$content = '';
foreach (self::getOrderedClasses($classes) as $class) {
Expand All @@ -126,19 +126,19 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =
$c = file_get_contents($file);

if (preg_match($dontInlineRegex, $c)) {
$file = explode(DIRECTORY_SEPARATOR, $file);
$file = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $file));

for ($i = 0; isset($file[$i], $cacheDir[$i]); ++$i) {
if ($file[$i] !== $cacheDir[$i]) {
break;
}
}
if (1 >= $i) {
$file = var_export(implode(DIRECTORY_SEPARATOR, $file), true);
$file = var_export(implode('/', $file), true);
} else {
$file = array_slice($file, $i);
$file = str_repeat('..'.DIRECTORY_SEPARATOR, count($cacheDir) - $i).implode(DIRECTORY_SEPARATOR, $file);
$file = '__DIR__.'.var_export(DIRECTORY_SEPARATOR.$file, true);
$file = str_repeat('../', count($cacheDir) - $i).implode('/', $file);
$file = '__DIR__.'.var_export('/'.$file, true);
}

$c = "\nnamespace {require $file;}";
Expand Down

0 comments on commit 6d1f1b5

Please sign in to comment.