From 451a92001f16c9059a0c0d46d815909aa27eaa18 Mon Sep 17 00:00:00 2001 From: atodd Date: Tue, 25 Jun 2013 14:00:43 -0400 Subject: [PATCH 1/3] Add option to sort classmap list --- bin/classmap_generator.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/classmap_generator.php b/bin/classmap_generator.php index b4f17a3325f..726645bed70 100755 --- a/bin/classmap_generator.php +++ b/bin/classmap_generator.php @@ -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 { @@ -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); @@ -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); From 925e3aa4d8f83c38604e284c3236164b7059650e Mon Sep 17 00:00:00 2001 From: atodd Date: Tue, 25 Jun 2013 16:49:06 -0400 Subject: [PATCH 2/3] add docblock comment --- bin/classmap_generator.php | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/classmap_generator.php b/bin/classmap_generator.php index 726645bed70..7c69edc1233 100755 --- a/bin/classmap_generator.php +++ b/bin/classmap_generator.php @@ -25,6 +25,7 @@ * --overwrite|-w Whether or not to overwrite existing autoload * file * --ignore|-i [ ] Comma-separated namespaces to ignore + * --sort|-s Alphabetically sort classes */ $zfLibraryPath = getenv('LIB_PATH') ? getenv('LIB_PATH') : __DIR__ . '/../library'; From 200c15b3f0a21c5f836e81d53cb7f809b9d1a218 Mon Sep 17 00:00:00 2001 From: atodd Date: Wed, 26 Jun 2013 09:21:02 -0400 Subject: [PATCH 3/3] use same variable name for map array, just change the type --- bin/classmap_generator.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/classmap_generator.php b/bin/classmap_generator.php index 7c69edc1233..ea3f8d60310 100755 --- a/bin/classmap_generator.php +++ b/bin/classmap_generator.php @@ -176,13 +176,13 @@ } } -$classmap_array = (array) $map; +$map = (array) $map; if ($opts->getOption('s')) { - ksort($classmap_array); + ksort($map); } if ($appending) { - $content = var_export($classmap_array, true) . ';'; + $content = var_export($map, true) . ';'; // Prefix with __DIR__; modify the generated content $content = preg_replace("#(=> ')#", "=> __DIR__ . '/", $content); @@ -205,7 +205,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($classmap_array, true) . ';'; + . 'return ' . var_export($map, true) . ';'; // Prefix with __DIR__; modify the generated content $content = preg_replace("#(=> ')#", "=> __DIR__ . '/", $content);