40 if (
false === include(
'Zend/Loader/StandardAutoloader.php')) {
41 echo
"Unable to locate autoloader via include_path; aborting" . PHP_EOL;
46 if (
false === include(dirname(
__FILE__) .
'/../library/Zend/Loader/StandardAutoloader.php')) {
47 echo
"Unable to locate autoloader via library; aborting" . PHP_EOL;
56 $loader->setFallbackAutoloader(
true);
60 'help|h' =>
'Get usage message',
61 'library|l-s' =>
'Library to parse; if none provided, assumes current directory',
62 'output|o-s' =>
'Where to write autoload file; if not provided, assumes "autoload_classmap.php" in library directory',
63 'append|a' =>
'Append to autoload file if it exists',
64 'overwrite|w' =>
'Whether or not to overwrite existing autoload file',
65 'ignore|i-s' =>
'Comma-separated namespaces to ignore',
76 if (
$opts->getOption(
'h')) {
77 echo
$opts->getUsageMessage();
82 if (isset(
$opts->i)) {
87 if (isset(
$opts->l)) {
89 echo
'Invalid library directory provided' . PHP_EOL
91 echo
$opts->getUsageMessage();
101 if (isset(
$opts->o)) {
107 echo
'Invalid output file provided' . PHP_EOL
109 echo
$opts->getUsageMessage();
112 echo
"Cannot write to '$output'; aborting." . PHP_EOL
114 .
$opts->getUsageMessage();
117 echo
"Autoload file already exists at '$output'," . PHP_EOL
118 .
"but 'overwrite' or 'appending' flag was not specified; aborting." . PHP_EOL
120 .
$opts->getUsageMessage();
124 $classmapPath = str_replace(DIRECTORY_SEPARATOR,
'/', realpath(dirname(
$output)));
131 $classmapPathParts = explode(
'/', $classmapPath);
134 $count = count($classmapPathParts);
136 if (!isset($libraryPathParts[
$i]) || $libraryPathParts[
$i] != $classmapPathParts[
$i]) {
146 $count = count($libraryPathParts);
156 echo
"Appending to class file map '$output' for library in '$libraryPath'..." . PHP_EOL;
158 echo
"Creating class file map for library in '$libraryPath'..." . PHP_EOL;
168 foreach (
$l as $file) {
169 $filename = str_replace(
$libraryPath .
'/',
'', str_replace(DIRECTORY_SEPARATOR,
'/', $file->getPath()) .
'/' . $file->getFilename());
174 foreach ($file->getClasses() as
$class) {
176 if ($ignoreNs == substr(
$class, 0, strlen($ignoreNs))) {
199 $existing = file(
$output, FILE_IGNORE_NEW_LINES);
200 array_pop($existing);
208 .
"// Generated by ZF's ./bin/classmap_generator.php\n" 209 .
'return ' . var_export((array)
$map,
true) .
';';
225 preg_match_all(
'(\n\s+([^=]+)=>)',
$content, $matches, PREG_SET_ORDER);
228 foreach ($matches as $match) {
232 $content = preg_replace(
'(\n\s+([^=]+)=>)e',
"'\n \\1' . str_repeat(' ', " .
$maxWidth .
" - strlen('\\1')) . '=>'",
$content);
241 echo
"Wrote classmap file to '" . realpath(
$output) .
"'" . PHP_EOL;
catch(Zend_Console_Getopt_Exception $e) if($opts->getOption('h')) $ignoreNamespaces
elseif(isset( $params[ 'redirect_parent']))
defined('MTF_BOOT_FILE')||define('MTF_BOOT_FILE' __FILE__
$_option $_optionId $class
if(isset($opts->i)) $relativePathForClassmap
if(isset($opts->l)) $libraryPath
if(isset($opts->o)) if(! $usingStdout) $l