Skip to content

Commit

Permalink
Windows classmap portability
Browse files Browse the repository at this point in the history
- Paths should use DIRECTORY_SEPARATOR concatenation to ensure
  portability when generated on Windows and pushed to *nix
  - "' . DIRECTORY_SEPARATOR . '" replaces actual character
  - which requires replacing "\'" with "'" in final generation
  • Loading branch information
weierophinney committed May 23, 2011
1 parent 52eacb2 commit 2513650
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bin/classmap_generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@
$namespace = empty($file->namespace) ? '' : $file->namespace . '\\';
$filename = str_replace($strip, '', $file->getRealpath());

// Replace directory separators with constant
$filename = str_replace(array('/', '\\'), "' . DIRECTORY_SEPARATOR . '", $filename);

$map->{$namespace . $file->classname} = $filename;

return true;
Expand All @@ -139,6 +142,9 @@
// Prefix with __DIR__; modify the generated content
$content = preg_replace('#(=> )#', '$1__DIR__ . DIRECTORY_SEPARATOR . ', $content);

// Fix \' strings from injected DIRECTORY_SEPARATOR usage in iterator_apply op
$content = str_replace("\\'", "'", $content);

// Write the contents to disk
file_put_contents($output, $content);

Expand Down

0 comments on commit 2513650

Please sign in to comment.