Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions bin/classmap_generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* --overwrite|-w Whether or not to overwrite existing autoload
* file
* --ignore|-i [ <string> ] Comma-separated namespaces to ignore
* --sort|-s Alphabetically sort classes
*/

$zfLibraryPath = getenv('LIB_PATH') ? getenv('LIB_PATH') : __DIR__ . '/../library';
Expand Down Expand Up @@ -55,6 +56,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 +176,13 @@
}
}

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

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

// Prefix with __DIR__; modify the generated content
$content = preg_replace("#(=> ')#", "=> __DIR__ . '/", $content);
Expand All @@ -198,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((array) $map, true) . ';';
. 'return ' . var_export($map, true) . ';';

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