Skip to content
This repository was archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
Add option to sort classmap list
Browse files Browse the repository at this point in the history
  • Loading branch information
atodd committed Jun 25, 2013
1 parent 70ed53e commit 451a920
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bin/classmap_generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
'append|a' => 'Append to autoload file if it exists',
'overwrite|w' => 'Whether or not to overwrite existing autoload file',
'ignore|i-s' => 'Comma-separated namespaces to ignore',
'sort|s' => 'Alphabetically sort classes',
);

try {
Expand Down Expand Up @@ -174,8 +175,13 @@
}
}

$classmap_array = (array) $map;
if ($opts->getOption('s')) {
ksort($classmap_array);
}

if ($appending) {
$content = var_export((array) $map, true) . ';';
$content = var_export($classmap_array, true) . ';';

// Prefix with __DIR__; modify the generated content
$content = preg_replace("#(=> ')#", "=> __DIR__ . '/", $content);
Expand All @@ -198,7 +204,7 @@
// Stupid syntax highlighters make separating < from PHP declaration necessary
$content = '<' . "?php\n"
. "// Generated by ZF2's ./bin/classmap_generator.php\n"
. 'return ' . var_export((array) $map, true) . ';';
. 'return ' . var_export($classmap_array, true) . ';';

// Prefix with __DIR__; modify the generated content
$content = preg_replace("#(=> ')#", "=> __DIR__ . '/", $content);
Expand Down

0 comments on commit 451a920

Please sign in to comment.