/** * Main method. */ public function main() { $input = new ezcConsoleInput(); $output = new ezcConsoleOutput(); $input->registerOption(new ezcConsoleOption('', 'count-tests', ezcConsoleInput::TYPE_NONE, FALSE, FALSE)); $input->registerOption(new ezcConsoleOption('', 'exclude', ezcConsoleInput::TYPE_STRING, array(), TRUE)); $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); $input->registerOption(new ezcConsoleOption('', 'log-xml', ezcConsoleInput::TYPE_STRING)); $input->registerOption(new ezcConsoleOption('', 'log-csv', ezcConsoleInput::TYPE_STRING)); $input->registerOption(new ezcConsoleOption('', 'suffixes', ezcConsoleInput::TYPE_STRING, 'php', FALSE)); $input->registerOption(new ezcConsoleOption('v', 'version', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); $input->registerOption(new ezcConsoleOption('', 'progress', ezcConsoleInput::TYPE_NONE)); try { $input->process(); } catch (ezcConsoleOptionException $e) { print $e->getMessage() . "\n"; exit(1); } if ($input->getOption('help')->value) { $this->showHelp(); exit(0); } else { if ($input->getOption('version')->value) { $this->printVersionString(); exit(0); } } $arguments = $input->getArguments(); if (empty($arguments)) { $this->showHelp(); exit(1); } $countTests = $input->getOption('count-tests')->value; $excludes = $input->getOption('exclude')->value; $logXml = $input->getOption('log-xml')->value; $logCsv = $input->getOption('log-csv')->value; $suffixes = array_map('trim', explode(',', $input->getOption('suffixes')->value)); if ($input->getOption('progress')->value !== FALSE) { $progress = $output; } else { $progress = NULL; } $this->printVersionString(); $files = $this->findFiles($arguments, $excludes, $suffixes); if (empty($files)) { $this->showError("No files found to scan.\n"); } $analyser = new PHPLOC_Analyser($progress); $count = $analyser->countFiles($files, $countTests); $printer = new PHPLOC_TextUI_ResultPrinter_Text(); $printer->printResult($count, $countTests); if ($logXml) { $printer = new PHPLOC_TextUI_ResultPrinter_XML(); $printer->printResult($logXml, $count); } if ($logCsv) { $printer = new PHPLOC_TextUI_ResultPrinter_CSV(); $printer->printResult($logCsv, $count); } }
/** * Main method. */ public function main() { $input = new ezcConsoleInput(); $output = new ezcConsoleOutput(); $input->registerOption(new ezcConsoleOption('', 'exclude', ezcConsoleInput::TYPE_STRING, array(), TRUE)); $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); $input->registerOption(new ezcConsoleOption('', 'recursive', ezcConsoleInput::TYPE_NONE)); $input->registerOption(new ezcConsoleOption('', 'suffixes', ezcConsoleInput::TYPE_STRING, 'php', FALSE)); $input->registerOption(new ezcConsoleOption('v', 'version', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); $input->registerOption(new ezcConsoleOption('', 'verbose', ezcConsoleInput::TYPE_NONE)); try { $input->process(); } catch (ezcConsoleOptionException $e) { print $e->getMessage() . "\n"; exit(1); } if ($input->getOption('help')->value) { $this->showHelp(); exit(0); } else { if ($input->getOption('version')->value) { $this->printVersionString(); exit(0); } } $arguments = $input->getArguments(); if (empty($arguments)) { $this->showHelp(); exit(1); } $excludes = $input->getOption('exclude')->value; $recursive = $input->getOption('recursive')->value; $suffixes = explode(',', $input->getOption('suffixes')->value); array_map('trim', $suffixes); if ($input->getOption('verbose')->value !== FALSE) { $verbose = $output; } else { $verbose = NULL; } $this->printVersionString(); $files = $this->findFiles($arguments, $excludes, $suffixes); if (empty($files)) { $this->showError("No files found to scan.\n"); } $detector = new PHPDCD_Detector($verbose); $result = $detector->detectDeadCode($files, $recursive); $printer = new PHPDCD_TextUI_ResultPrinter(); $printer->printResult($result, $commonPath); unset($printer); }
public function main() { $input = new \ezcConsoleInput(); $output = new \ezcConsoleOutput(); $input->registerOption(new \ezcConsoleOption('h', 'help')); $input->registerOption(new \ezcConsoleOption('p', 'process')); $input->process(); if ($input->getOption("p")->value) { $parser = new PHPLpm\Parser(); $result = $parser->parse(file_get_contents("_testdata/sample.php", 1)); $table = new \ezcConsoleTable($output, 60); $table[0][0]->content = "Class"; $table[0][1]->content = "Method"; $table[0][2]->content = "Lines"; $i = 1; foreach ($result as $class => $methods) { foreach ($methods as $method) { $row = $table[$i]; $row[0]->content = $class; $row[1]->content = $method["name"]; $row[2]->content = (string) $method["lines"]; $i++; } } $table->outputTable(); print "\n"; //print_r($result); } }
/** * Main method. */ public static function main() { $input = new ezcConsoleInput(); $input->registerOption(new ezcConsoleOption('', 'bootstrap', ezcConsoleInput::TYPE_STRING)); $input->registerOption(new ezcConsoleOption('', 'class', ezcConsoleInput::TYPE_NONE)); $input->registerOption(new ezcConsoleOption('', 'test', ezcConsoleInput::TYPE_NONE)); $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); $input->registerOption(new ezcConsoleOption('v', 'version', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); try { $input->process(); } catch (ezcConsoleOptionException $e) { print $e->getMessage() . "\n"; exit(1); } if ($input->getOption('help')->value) { self::showHelp(); exit(0); } else { if ($input->getOption('version')->value) { self::printVersionString(); exit(0); } } $arguments = $input->getArguments(); $bootstrap = $input->getOption('bootstrap')->value; $class = $input->getOption('class')->value; $test = $input->getOption('test')->value; if (empty($arguments) || !$class && !$test || $class && $test) { self::showHelp(); exit(1); } if ($class) { $reflector = new ReflectionClass('PHPUnit_SkeletonGenerator_Class'); } else { if ($test) { $reflector = new ReflectionClass('PHPUnit_SkeletonGenerator_Test'); } } self::printVersionString(); if ($bootstrap && file_exists($bootstrap)) { include $bootstrap; } $generator = $reflector->newInstanceArgs($arguments); $generator->write(); printf('Wrote skeleton for "%s" to "%s".' . "\n", $generator->getOutClassName(), $generator->getOutSourceFile()); exit(0); }
/** * Displays messages * * @var string $message Message to display * @var string $type Type of the message * @return void */ public static function displayMessage($message, $type = 'info') { if ('info' == $type && !self::$consoleInput->getOption('verbose')->value) { return; } elseif ('debug' == $type && !self::$consoleInput->getOption('debug')->value) { return; } self::$consoleOutput->outputText("{$message}\n", $type); }
/** * Main method. */ public static function main() { $input = new ezcConsoleInput(); $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); $input->registerOption(new ezcConsoleOption('v', 'version', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); try { $input->process(); } catch (ezcConsoleOptionException $e) { print $e->getMessage() . "\n"; exit(1); } if ($input->getOption('help')->value) { self::showHelp(); exit(0); } else { if ($input->getOption('version')->value) { self::printVersionString(); exit(0); } } $arguments = $input->getArguments(); if (empty($arguments)) { self::showHelp(); exit(1); } self::printVersionString(); print "Line Token Text\n" . str_repeat('-', 79) . "\n"; foreach (new PHP_Token_Stream($arguments[0]) as $token) { if ($token instanceof PHP_Token_WHITESPACE) { $text = ''; } else { $text = str_replace(array("\r", "\n"), '', (string) $token); if (strlen($text) > 40) { $text = explode("\n", wordwrap($text, 40)); $text = $text[0]; } } printf("%5d %-30s %s\n", $token->getLine(), str_replace('PHP_Token_', '', get_class($token)), $text); } }
/** * Generates help information as a multidimensional array, grouped in categories. * * This method behaves similar to {@link generateUngroupedOptionHelp()}. In * contrast to the latter one, this method returns an array with 1 * dimension more, grouping options into categories. The $groups parameter * defines the categories to generate. Each category may contain an * arbitrary number of options, options might occur in different * categories. * * The returned array has the follorwing format: * * <code> * <?php * array( * '<category name>' => array( * 0 => array( * 0 => '<option short/long name>', * 1 => '<option help, depending on the $long parameter>' * ), * 1 => array( * 0 => '<option short name> / <option long name>', * 1 => '<option help, depending on the $long parameter>' * ), * // ... * ), * '<category name>' => array( * // ... * ), * // ... * ); * ?> * </code> * * The $long parameter, as in {@link generateUngroupedOptionHelp()} * determines if the options short or long help is to be used. The * $params array can in addition be used to determine if a parameter * is displayed at all. If $optionsFilter is submitted and is not null, * only options listed in it will be shown in the help at all. * * @param array(string=>array(string)) $groups * @param bool $long * @param array(string) $params * @return array(string=>array(array(string))) */ public function generateGroupedOptionHelp(array $groups, $long = false, array $optionsFilter = null) { $help = array(); foreach ($groups as $groupName => $groupOptions) { foreach ($groupOptions as $optionName) { $option = $this->input->getOption($optionName); if ($optionsFilter === null || in_array($option->short, $optionsFilter) || in_array($option->long, $optionsFilter)) { $help[$groupName][] = $this->getOptionHelpRow($long, $option); } } } return $help; }
/** * Writes classes or configuration using a template. * * This method uses the given $tpl file to output $schema to $dir. $tpl is * either a template for PersistentObject definition files or * PersistentObject class stubs. * * @param string $dir * @param ezcDbSchema $schema * @param string $tpl */ private function writeFromTemplate($dir, $schema, $tpl) { $writer = new ezcPersistentObjectTemplateSchemaWriter(); if (($tplPath = $this->input->getOption('template-path')->value) !== false) { $writer->options->templatePath = $tplPath; } if (($prefix = $this->input->getOption('prefix')->value) !== false) { $writer->options->classPrefix = $prefix; } if (($overwrite = $this->input->getOption('overwrite')->value) !== false) { $writer->options->overwrite = $overwrite; } $writer->write($schema, $tpl, $dir); }
/** * Run the generator. * Process the given options and generate a PersistentObject definition from it. * * @return void */ public function run() { try { $this->input->process(); } catch (ezcConsoleException $e) { $this->raiseError("Error while processing your options: {$e->getMessage()}", true); } if ($this->input->getOption('h')->value === true) { $this->output->outputText($this->input->getHelpText(ezcPersistentObjectSchemaGenerator::PROGRAM_DESCRIPTION, 80, true), "help"); exit(0); } $defDir = $this->input->argumentDefinition["def dir"]->value; $classDir = $this->input->argumentDefinition["class dir"]->value; $schema = null; try { $readerClass = ezcDbSchemaHandlerManager::getReaderByFormat($this->input->getOption("format")->value); $reader = new $readerClass(); switch (true) { case $reader instanceof ezcDbSchemaDbReader: $db = ezcDbFactory::create($this->input->getOption("source")->value); $schema = ezcDbSchema::createFromDb($db); break; case $reader instanceof ezcDbSchemaFileReader: $schema = ezcDbSchema::createFromFile($this->input->getOption("format")->value, $this->input->getOption("source")->value); break; default: $this->raiseError("Reader class not supported: '{$readerClass}'."); break; } } catch (Exception $e) { $this->raiseError("Error reading schema: {$e->getMessage()}"); } try { $writer = new ezcDbSchemaPersistentWriter($this->input->getOption("overwrite")->value, $this->input->getOption("prefix")->value); $writer->saveToFile($defDir, $schema); if ($classDir !== null) { $writer = new ezcDbSchemaPersistentClassWriter($this->input->getOption("overwrite")->value, $this->input->getOption("prefix")->value); $writer->saveToFile($classDir, $schema); } } catch (ezcBaseException $e) { $this->raiseError("Error writing schema: {$e->getMessage()}"); } $this->output->outputLine("PersistentObject definition successfully written to {$defDir}.", 'info'); if ($classDir !== null) { $this->output->outputLine("Class files successfully written to {$classDir}.", 'info'); } }
/** * Get translations for given context. * * @param string $contextName * @return array(string=>ezcTranslationData) */ function getTranslationsFromTsFile($contextName) { $translationMapOriginal = array(); try { // get the original context $context = $this->backend->getContext($this->input->getOption("locale")->value, $contextName); // store all existing translations in associative array foreach ($context as $translationElement) { $translationMapOriginal[$translationElement->original] = $translationElement; } } catch (ezcTranslationMissingTranslationFileException $e) { // no ts file existing yet } catch (ezcTranslationContextNotAvailableException $e) { // no context of this name existing yet } return $translationMapOriginal; }
/** * starts the command line interface for pFlow * @return void */ public function run() { $this->setupInput(); try { $this->input->process(); } catch (\ezcConsoleOptionException $e) { die($e->getMessage() . "\nTry option -h to get a list of available options.\n"); } catch (\ezcConsoleArgumentMandatoryViolationException $e) { die($e->getMessage() . "\nTry option -h to get a list of available options.\n"); } if ($this->input->helpOptionSet()) { echo $this->input->getHelpText("\npFlow version " . self::VERSION . "\n\n" . "A tool for analysing control and data flow in PHP applications."); } else { // start generation $this->analyzer->setSources($this->input->getArguments(), $this->input->getOption('recursive')->value); } }
$option = $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, null, FALSE)); $option->isHelpOption = TRUE; $option->arguments = FALSE; $option = $input->registerOption(new ezcConsoleOption('d', 'dir', ezcConsoleInput::TYPE_STRING, '.', FALSE, 'Search Directory.', 'Directory to search for php class files, defaults to .')); $option->arguments = FALSE; $option = $input->registerOption(new ezcConsoleOption('t', 'target', ezcConsoleInput::TYPE_STRING, './autoload', FALSE, 'autoload dir', 'The directory where to save the autoload file, defaults to ./autoload')); $option->arguments = FALSE; $option = $input->registerOption(new ezcConsoleOption('p', 'prefix', ezcConsoleInput::TYPE_STRING, null, FALSE, 'classes prefix', 'The prefix of the classes for which the autoload file should be created')); $option->arguments = FALSE; $input->registerOption(new ezcConsoleOption('b', 'basedir', ezcConsoleInput::TYPE_STRING, '.', FALSE, 'basedir for autoload paths', 'Paths in the autoload array are written relatively to this dir. Defaults to .')); try { $input->process(); } catch (ezcConsoleOptionException $e) { die($e->getMessage() . "\n"); } if ($input->getOption('h')->value === true) { echo $input->getHelpText('eZ components autoload generator'); die; } foreach (array('dir', 'target', 'basedir') as $option) { ${$option} = realpath($input->getOption($option)->value); if (FALSE === ${$option}) { echo 'Given directory ' . $input->getOption($option)->value . ' for option ' . $option . " does not exist.\n"; die; } } $prefix = $input->getOption('p')->value; chdir($basedir); $relPath = relPath($basedir, $dir); $iterator = new DirectoryIteratorFilter($relPath); foreach ($iterator as $file) {
/** * Processes all console options * * If the help option is specified by the user the help text will be * displayed and the program will exit. * * @param ezcConsoleInput $consoleInput */ protected static function processConsoleArguments($consoleInput) { try { $consoleInput->process(); } catch (ezcConsoleOptionException $e) { die($e->getMessage() . "\n"); } if ($consoleInput->getOption("help")->value) { self::displayHelp(self::$consoleInput); exit; } if ($consoleInput->getOption('php-binary')->value) { self::$phpBinary = $consoleInput->getOption('php-binary')->value; } }
* @param string $className */ function __autoload($className) { ezcBase::autoload($className); } $optionHandler = new ezcConsoleInput(); // Register simple parameter -h/--help $optionHandler->registerOption(new ezcConsoleOption('h', 'help')); // Register complex parameter -f/--file $file = new ezcConsoleOption('f', 'file', ezcConsoleInput::TYPE_STRING, null, false, 'Process a file.', 'Processes a single file.'); $optionHandler->registerOption($file); // Manipulate parameter -f/--file after registration $file->multiple = true; // Register another complex parameter that depends on -f and excludes -h $dir = new ezcConsoleOption('d', 'dir', ezcConsoleInput::TYPE_STRING, null, true, 'Process a directory.', 'Processes a complete directory.', array(new ezcConsoleOptionRule($optionHandler->getOption('f'))), array(new ezcConsoleOptionRule($optionHandler->getOption('h')))); $optionHandler->registerOption($dir); // Register an alias for this parameter $optionHandler->registerAlias('e', 'extended-dir', $dir); // Process registered parameters and handle errors try { $optionHandler->process(array('example_input.php', '-h')); } catch (ezcConsoleOptionException $e) { echo $e->getMessage(); exit(1); } // Process a single parameter $file = $optionHandler->getOption('f'); if ($file->value === false) { echo "Parameter -{$file->short}/--{$file->long} was not submitted.\n"; } elseif ($file->value === true) {
/** * Main method. */ public static function main() { $input = new ezcConsoleInput(); $input->registerOption(new ezcConsoleOption('', 'clover', ezcConsoleInput::TYPE_STRING)); $input->registerOption(new ezcConsoleOption('', 'html', ezcConsoleInput::TYPE_STRING)); $input->registerOption(new ezcConsoleOption('', 'blacklist', ezcConsoleInput::TYPE_STRING, array(), TRUE)); $input->registerOption(new ezcConsoleOption('', 'whitelist', ezcConsoleInput::TYPE_STRING, array(), TRUE)); $input->registerOption(new ezcConsoleOption('', 'merge', ezcConsoleInput::TYPE_NONE, FALSE)); $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); $input->registerOption(new ezcConsoleOption('v', 'version', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); try { $input->process(); } catch (ezcConsoleOptionException $e) { print $e->getMessage() . "\n"; exit(1); } if ($input->getOption('help')->value) { self::showHelp(); exit(0); } else { if ($input->getOption('version')->value) { self::printVersionString(); exit(0); } } $arguments = $input->getArguments(); $clover = $input->getOption('clover')->value; $html = $input->getOption('html')->value; $blacklist = $input->getOption('blacklist')->value; $whitelist = $input->getOption('whitelist')->value; $merge = $input->getOption('merge')->value; if (count($arguments) == 1) { self::printVersionString(); $coverage = new PHP_CodeCoverage(); $filter = $coverage->filter(); if (empty($whitelist)) { $c = new ReflectionClass('ezcBase'); $filter->addDirectoryToBlacklist(dirname($c->getFileName())); $c = new ReflectionClass('ezcConsoleInput'); $filter->addDirectoryToBlacklist(dirname($c->getFileName())); foreach ($blacklist as $item) { if (is_dir($item)) { $filter->addDirectoryToBlacklist($item); } else { if (is_file($item)) { $filter->addFileToBlacklist($item); } } } } else { foreach ($whitelist as $item) { if (is_dir($item)) { $filter->addDirectoryToWhitelist($item); } else { if (is_file($item)) { $filter->addFileToWhitelist($item); } } } } if (!$merge) { $coverage->start('phpcov'); require $arguments[0]; $coverage->stop(); } else { $facade = new File_Iterator_Facade(); $result = $facade->getFilesAsArray($arguments[0], '.cov'); foreach ($files as $file) { $coverage->merge(unserialize(file_get_contents($file))); } } if ($clover) { $writer = new PHP_CodeCoverage_Report_Clover(); $writer->process($coverage, $clover); } if ($html) { $writer = new PHP_CodeCoverage_Report_HTML(); $writer->process($coverage, $html); } } else { self::showHelp(); exit(1); } }
public function testFromStringSuccess() { $param = new ezcConsoleInput(); $param->registerOptionString('[a:|all:][u?|user?][i|info][o+test|overall+][d*|destroy*]'); $res['a'] = new ezcConsoleOption('a', 'all', ezcConsoleInput::TYPE_NONE, NULL, false, 'No help available.', 'Sorry, there is no help text available for this parameter.', array(), array(), true); $res['u'] = new ezcConsoleOption('u', 'user', ezcConsoleInput::TYPE_STRING, '', false, 'No help available.', 'Sorry, there is no help text available for this parameter.', array(), array(), true); $res['o'] = new ezcConsoleOption('o', 'overall', ezcConsoleInput::TYPE_STRING, 'test', true, 'No help available.', 'Sorry, there is no help text available for this parameter.', array(), array(), true); $res['d'] = new ezcConsoleOption('d', 'destroy', ezcConsoleInput::TYPE_NONE, null, true, 'No help available.', 'Sorry, there is no help text available for this parameter.', array(), array(), true); $this->assertEquals($res['a'], $param->getOption('a'), 'Option -a not registered correctly.'); $this->assertEquals($res['u'], $param->getOption('u'), 'Option -u not registered correctly.'); $this->assertEquals($res['o'], $param->getOption('o'), 'Option -o not registered correctly.'); $this->assertEquals($res['d'], $param->getOption('d'), 'Option -d not registered correctly.'); }
/** * Main method. */ public function main() { $input = new ezcConsoleInput(); $input->registerOption(new ezcConsoleOption('', 'eliminate-dead-code', ezcConsoleInput::TYPE_NONE)); $input->registerOption(new ezcConsoleOption('', 'exclude', ezcConsoleInput::TYPE_STRING, array(), TRUE)); $input->registerOption(new ezcConsoleOption('', 'format', ezcConsoleInput::TYPE_STRING, 'dot', FALSE)); $input->registerOption(new ezcConsoleOption('', 'graph', ezcConsoleInput::TYPE_STRING)); $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); $input->registerOption(new ezcConsoleOption('', 'log-pmd', ezcConsoleInput::TYPE_STRING)); $input->registerOption(new ezcConsoleOption('', 'rule', ezcConsoleInput::TYPE_STRING, array(), TRUE)); $input->registerOption(new ezcConsoleOption('', 'suffixes', ezcConsoleInput::TYPE_STRING, 'php', FALSE)); $input->registerOption(new ezcConsoleOption('v', 'version', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); try { $input->process(); } catch (ezcConsoleOptionException $e) { print $e->getMessage() . "\n"; exit(1); } if ($input->getOption('help')->value) { $this->showHelp(); exit(0); } else { if ($input->getOption('version')->value) { $this->printVersionString(); exit(0); } } $arguments = $input->getArguments(); if (empty($arguments)) { $this->showHelp(); exit(1); } $eliminateDeadCode = $input->getOption('eliminate-dead-code')->value; $excludes = $input->getOption('exclude')->value; $format = $input->getOption('format')->value; $graph = $input->getOption('graph')->value; $logPmd = $input->getOption('log-pmd')->value; $_rules = $input->getOption('rule')->value; $suffixes = explode(',', $input->getOption('suffixes')->value); array_map('trim', $suffixes); $rules = array(); foreach ($_rules as $rule) { $ruleOptions = ''; if (strpos($rule, ':') !== FALSE) { list($rule, $ruleOptions) = explode(':', $rule); } switch ($rule) { case 'DirectOutput': $rules[] = new Bytekit_Scanner_Rule_DirectOutput(); break; case 'DisallowedOpcodes': $disallowedOpcodes = explode(',', $ruleOptions); array_map('trim', $disallowedOpcodes); $rules[] = new Bytekit_Scanner_Rule_DisallowedOpcodes($disallowedOpcodes); break; case 'Output': $rules[] = new Bytekit_Scanner_Rule_Output(); break; case 'ZendView': $rules[] = new Bytekit_Scanner_Rule_ZendView(); break; } } $files = $this->findFiles($arguments, $excludes, $suffixes); if (empty($files)) { $this->showError("No files found to scan.\n"); } $this->printVersionString(); if (!empty($rules)) { $scanner = new Bytekit_Scanner($rules); $result = $scanner->scan($files); $formatter = new Bytekit_TextUI_ResultFormatter_Scanner_Text(); print $formatter->formatResult($result); if ($logPmd) { $formatter = new Bytekit_TextUI_ResultFormatter_Scanner_XML(); file_put_contents($logPmd, $formatter->formatResult($result)); } if (!empty($result)) { exit(1); } exit(0); } if (count($files) == 1) { $disassembler = new Bytekit_Disassembler($files[0]); if ($graph) { $result = $disassembler->disassemble(FALSE, $eliminateDeadCode); $formatter = new Bytekit_TextUI_ResultFormatter_Disassembler_Graph(); $formatter->formatResult($result, $graph, $format); } else { $result = $disassembler->disassemble(TRUE, $eliminateDeadCode); $formatter = new Bytekit_TextUI_ResultFormatter_Disassembler_Text(); print $formatter->formatResult($result); } exit(0); } }
/** * Main method. */ public function main() { $input = new \ezcConsoleInput(); $input->registerOption(new \ezcConsoleOption('', 'exclude', \ezcConsoleInput::TYPE_STRING, array(), TRUE)); $input->registerOption(new \ezcConsoleOption('h', 'help', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); $input->registerOption(new \ezcConsoleOption('', 'log-pmd', \ezcConsoleInput::TYPE_STRING)); $input->registerOption(new \ezcConsoleOption('', 'min-lines', \ezcConsoleInput::TYPE_INT, 5)); $input->registerOption(new \ezcConsoleOption('', 'min-tokens', \ezcConsoleInput::TYPE_INT, 70)); $input->registerOption(new \ezcConsoleOption('', 'names', \ezcConsoleInput::TYPE_STRING, '*.php', FALSE)); $input->registerOption(new \ezcConsoleOption('', 'quiet', \ezcConsoleInput::TYPE_NONE, NULL, FALSE)); $input->registerOption(new \ezcConsoleOption('v', 'version', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); $input->registerOption(new \ezcConsoleOption('', 'progress', \ezcConsoleInput::TYPE_NONE)); $input->registerOption(new \ezcConsoleOption('', 'verbose', \ezcConsoleInput::TYPE_NONE)); try { $input->process(); } catch (\ezcConsoleOptionException $e) { print $e->getMessage() . "\n"; exit(1); } if ($input->getOption('help')->value) { $this->showHelp(); exit(0); } else { if ($input->getOption('version')->value) { $this->printVersionString(); exit(0); } } $arguments = $input->getArguments(); if (empty($arguments)) { $this->showHelp(); exit(1); } $excludes = $input->getOption('exclude')->value; $logPmd = $input->getOption('log-pmd')->value; $minLines = $input->getOption('min-lines')->value; $minTokens = $input->getOption('min-tokens')->value; $names = explode(',', $input->getOption('names')->value); $quiet = $input->getOption('quiet')->value; $verbose = $input->getOption('verbose')->value; array_map('trim', $names); if ($input->getOption('progress')->value !== FALSE) { $output = new \ezcConsoleOutput(); } else { $output = NULL; } $this->printVersionString(); $finder = new FinderFacade($arguments, $excludes, $names); $files = $finder->findFiles(); if (empty($files)) { $this->showError("No files found to scan.\n"); } $strategy = new DefaultStrategy(); $detector = new Detector($strategy, $output); $clones = $detector->copyPasteDetection($files, $minLines, $minTokens); $printer = new ResultPrinter(); $printer->printResult($clones, !$quiet, $verbose); unset($printer); if ($logPmd) { $pmd = new PMD($logPmd); $pmd->processClones($clones); unset($pmd); } if (count($clones) > 0) { exit(1); } }
<?php require 'ezc-setup.php'; $optionHandler = new ezcConsoleInput(); $file = new ezcConsoleOption('f', 'file', ezcConsoleInput::TYPE_STRING); $file->mandatory = true; $optionHandler->registerOption($file); try { $optionHandler->process(); } catch (ezcConsoleException $e) { die($e->getMessage()); } echo "Processing file: ", $optionHandler->getOption('f')->value, "\n";
/** * Main method. */ public function main() { $input = new \ezcConsoleInput(); $input->registerOption(new \ezcConsoleOption('', 'clover', \ezcConsoleInput::TYPE_STRING)); $input->registerOption(new \ezcConsoleOption('', 'configuration', \ezcConsoleInput::TYPE_STRING)); $input->registerOption(new \ezcConsoleOption('', 'html', \ezcConsoleInput::TYPE_STRING)); $input->registerOption(new \ezcConsoleOption('', 'php', \ezcConsoleInput::TYPE_STRING)); $input->registerOption(new \ezcConsoleOption('', 'text', \ezcConsoleInput::TYPE_STRING)); $input->registerOption(new \ezcConsoleOption('', 'blacklist', \ezcConsoleInput::TYPE_STRING, array(), TRUE)); $input->registerOption(new \ezcConsoleOption('', 'whitelist', \ezcConsoleInput::TYPE_STRING, array(), TRUE)); $input->registerOption(new \ezcConsoleOption('', 'merge', \ezcConsoleInput::TYPE_NONE, FALSE)); $input->registerOption(new \ezcConsoleOption('', 'add-uncovered', \ezcConsoleInput::TYPE_NONE, FALSE)); $input->registerOption(new \ezcConsoleOption('', 'process-uncovered', \ezcConsoleInput::TYPE_NONE, FALSE)); $input->registerOption(new \ezcConsoleOption('h', 'help', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); $input->registerOption(new \ezcConsoleOption('v', 'version', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); try { $input->process(); } catch (ezcConsoleOptionException $e) { print $e->getMessage() . "\n"; exit(1); } if ($input->getOption('help')->value) { $this->showHelp(); exit(0); } else { if ($input->getOption('version')->value) { $this->printVersionString(); exit(0); } } $arguments = $input->getArguments(); $clover = $input->getOption('clover')->value; $configuration = $input->getOption('configuration')->value; $html = $input->getOption('html')->value; $php = $input->getOption('php')->value; $text = $input->getOption('text')->value; $blacklist = $input->getOption('blacklist')->value; $whitelist = $input->getOption('whitelist')->value; $addUncovered = $input->getOption('add-uncovered')->value; $processUncovered = $input->getOption('process-uncovered')->value; $merge = $input->getOption('merge')->value; $coverage = new \PHP_CodeCoverage(); $filter = $coverage->filter(); if ($configuration) { $this->handleConfiguration($configuration, $coverage); } if (count($arguments) == 1) { $this->printVersionString(); if (empty($whitelist)) { $c = new \ReflectionClass('ezcBase'); $filter->addDirectoryToBlacklist(dirname($c->getFileName())); $c = new \ReflectionClass('ezcConsoleInput'); $filter->addDirectoryToBlacklist(dirname($c->getFileName())); foreach ($blacklist as $item) { if (is_dir($item)) { $filter->addDirectoryToBlacklist($item); } else { if (is_file($item)) { $filter->addFileToBlacklist($item); } } } } else { $coverage->setAddUncoveredFilesFromWhitelist($addUncovered); $coverage->setProcessUncoveredFilesFromWhitelist($processUncovered); foreach ($whitelist as $item) { if (is_dir($item)) { $filter->addDirectoryToWhitelist($item); } else { if (is_file($item)) { $filter->addFileToWhitelist($item); } } } } if (!$merge) { $coverage->start('phpcov'); require $arguments[0]; $coverage->stop(); } else { $facade = new \File_Iterator_Facade(); $files = $facade->getFilesAsArray($arguments[0], '.cov'); foreach ($files as $file) { $coverage->merge(unserialize(file_get_contents($file))); } } if ($clover) { print "\nGenerating code coverage report in Clover XML format ..."; $writer = new \PHP_CodeCoverage_Report_Clover(); $writer->process($coverage, $clover); print " done\n"; } if ($html) { print "\nGenerating code coverage report in HTML format ..."; $writer = new \PHP_CodeCoverage_Report_HTML(); $writer->process($coverage, $html); print " done\n"; } if ($php) { print "\nGenerating code coverage report in PHP format ..."; $writer = new \PHP_CodeCoverage_Report_PHP(); $writer->process($coverage, $php); print " done\n"; } if ($text) { $writer = new \PHP_CodeCoverage_Report_Text(); $writer->process($coverage, $text); } } else { $this->showHelp(); exit(1); } }
/** * Main method. */ public static function main() { $input = new ezcConsoleInput(); $input->registerOption(new ezcConsoleOption('', 'clover', ezcConsoleInput::TYPE_STRING)); $input->registerOption(new ezcConsoleOption('', 'html', ezcConsoleInput::TYPE_STRING)); $input->registerOption(new ezcConsoleOption('', 'php', ezcConsoleInput::TYPE_STRING)); $input->registerOption(new ezcConsoleOption('', 'text', ezcConsoleInput::TYPE_STRING)); $input->registerOption(new ezcConsoleOption('', 'blacklist', ezcConsoleInput::TYPE_STRING, array(), TRUE)); $input->registerOption(new ezcConsoleOption('', 'whitelist', ezcConsoleInput::TYPE_STRING, array(), TRUE)); $input->registerOption(new ezcConsoleOption('', 'merge', ezcConsoleInput::TYPE_NONE, FALSE)); $input->registerOption(new ezcConsoleOption('', 'add-uncovered', ezcConsoleInput::TYPE_NONE, FALSE)); $input->registerOption(new ezcConsoleOption('', 'process-uncovered', ezcConsoleInput::TYPE_NONE, FALSE)); $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); $input->registerOption(new ezcConsoleOption('v', 'version', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); try { $input->process(); } catch (ezcConsoleOptionException $e) { print $e->getMessage() . "\n"; exit(1); } if ($input->getOption('help')->value) { self::showHelp(); exit(0); } else { if ($input->getOption('version')->value) { self::printVersionString(); exit(0); } } $arguments = $input->getArguments(); $clover = $input->getOption('clover')->value; $html = $input->getOption('html')->value; $php = $input->getOption('php')->value; $text = $input->getOption('text')->value; $blacklist = $input->getOption('blacklist')->value; $whitelist = $input->getOption('whitelist')->value; $addUncovered = $input->getOption('add-uncovered')->value; $processUncovered = $input->getOption('process-uncovered')->value; $merge = $input->getOption('merge')->value; if (count($arguments) == 1) { self::printVersionString(); $coverage = new PHP_CodeCoverage(); $filter = $coverage->filter(); if (empty($whitelist)) { $c = new ReflectionClass('ezcBase'); $filter->addDirectoryToBlacklist(dirname($c->getFileName())); $c = new ReflectionClass('ezcConsoleInput'); $filter->addDirectoryToBlacklist(dirname($c->getFileName())); foreach ($blacklist as $item) { if (is_dir($item)) { $filter->addDirectoryToBlacklist($item); } else { if (is_file($item)) { $filter->addFileToBlacklist($item); } } } } else { $coverage->setAddUncoveredFilesFromWhitelist($addUncovered); $coverage->setProcessUncoveredFilesFromWhitelist($processUncovered); foreach ($whitelist as $item) { if (is_dir($item)) { $filter->addDirectoryToWhitelist($item); } else { if (is_file($item)) { $filter->addFileToWhitelist($item); } } } } if (!$merge) { $coverage->start('phpcov'); require $arguments[0]; $coverage->stop(); } else { $finder = new Symfony\Component\Finder\Finder(); $finder->in($arguments[0])->name('*.cov'); foreach ($finder as $file) { $coverage->merge(unserialize(file_get_contents($file->getRealpath()))); } } if ($clover) { $writer = new PHP_CodeCoverage_Report_Clover(); $writer->process($coverage, $clover); } if ($html) { $writer = new PHP_CodeCoverage_Report_HTML(); $writer->process($coverage, $html); } if ($php) { $writer = new PHP_CodeCoverage_Report_PHP(); $writer->process($coverage, $php); } if ($text) { $writer = new PHP_CodeCoverage_Report_Text(); $writer->process($coverage, $text); } } else { self::showHelp(); exit(1); } }
/** * Main function. Sets up the environment and coordinate the work. * * @return void */ public static function run() { // Set autoload up require_once 'PHP/ConfigReport/Loader.php'; spl_autoload_register(array('PHP_ConfigReport_Loader', 'autoload')); require_once 'ezc/Base/base.php'; spl_autoload_register(array('ezcBase', 'autoload')); // Set console output up $output = new ezcConsoleOutput(); $output->formats->version->style = array('bold'); $output->formats->debug->color = 'yellow'; $output->formats->debug->style = array('italic'); $output->formats->error->color = 'red'; self::$_consoleOutput = $output; // Set console input up $input = new ezcConsoleInput(); self::$_consoleInput = $input; $debugOption = new ezcConsoleOption('d', 'debug'); $debugOption->type = ezcConsoleInput::TYPE_NONE; $input->registerOption($debugOption); $environmentOption = new ezcConsoleOption('e', 'environment'); $environmentOption->type = ezcConsoleInput::TYPE_STRING; $environmentOption->default = 'production'; $input->registerOption($environmentOption); $helpOption = new ezcConsoleOption('h', 'help'); $helpOption->type = ezcConsoleInput::TYPE_NONE; $input->registerOption($helpOption); $phpDirectiveOption = new ezcConsoleOption('p', 'php'); $phpDirectiveOption->type = ezcConsoleInput::TYPE_STRING; $phpDirectiveOption->multiple = true; $input->registerOption($phpDirectiveOption); $phpVersionOption = new ezcConsoleOption(null, 'php-version'); $phpVersionOption->type = ezcConsoleInput::TYPE_STRING; $input->registerOption($phpVersionOption); $verboseOption = new ezcConsoleOption('v', 'verbose'); $verboseOption->type = ezcConsoleInput::TYPE_NONE; $input->registerOption($verboseOption); $loadedExtensionsOption = new ezcConsoleOption('x', 'extensions'); $loadedExtensionsOption->type = ezcConsoleInput::TYPE_STRING; $input->registerOption($loadedExtensionsOption); $widthOption = new ezcConsoleOption(null, 'width'); $widthOption->type = ezcConsoleInput::TYPE_INT; $input->registerOption($widthOption); $versionOption = new ezcConsoleOption(null, 'version'); $versionOption->type = ezcConsoleInput::TYPE_NONE; $input->registerOption($versionOption); // Process console input try { $input->process(); } catch (ezcConsoleOptionException $exception) { echo $exception->getMessage() . "\n"; exit(1); } if ($input->getOption('help')->value) { self::displayHelp(); exit(0); } else { if ($input->getOption('version')->value) { self::displayVersion(); exit(0); } } self::displayVersion(); if (false !== $input->getOption('php')->value) { foreach ($input->getOption('php')->value as $directive) { $position = strpos($directive, '='); if (false === $position) { throw new InvalidArgumentException("'{$directive}' is not a valid PHP configuration " . "directive"); } $name = substr($directive, 0, $position); $value = substr($directive, $position + 1); if (false === ini_set($name, $value)) { self::displayError("PHP directive {$name} could not be defined to {$value}"); } } unset($name, $value); } // Do the actual work try { $arguments = $input->getArguments(); $path = !empty($arguments[0]) ? $arguments[0] : null; $config = new PHP_ConfigReport_Config($path); if (false === $input->getOption('environment')->value) { $environment = null; } else { $environment = $input->getOption('environment')->value; } if (false === $input->getOption('extensions')->value) { $loadedExtensions = get_loaded_extensions(true); } else { $loadedExtensions = $input->getOption('extensions')->value; } if (false === $input->getOption('php-version')->value) { $phpVersion = PHP_VERSION; } else { $phpVersion = $input->getOption('php-version')->value; } $analyzer = new PHP_ConfigReport_Analyzer($config, $environment, $phpVersion, $loadedExtensions); $report = $analyzer->getReport(); if (false !== $input->getOption('width')->value) { $reportWidth = $input->getOption('width')->value; } else { $reportWidth = null; } $renderer = new PHP_ConfigReport_Renderer_Text($reportWidth); $renderer->render($report); } catch (Exception $exception) { self::displayError($exception->getMessage()); exit(1); } }
/** * Main method. */ public static function main() { $input = new ezcConsoleInput(); $output = new ezcConsoleOutput(); $input->registerOption(new ezcConsoleOption('', 'exclude', ezcConsoleInput::TYPE_STRING, array(), TRUE)); $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); $input->registerOption(new ezcConsoleOption('', 'log-pmd', ezcConsoleInput::TYPE_STRING)); $input->registerOption(new ezcConsoleOption('', 'min-lines', ezcConsoleInput::TYPE_INT, 5)); $input->registerOption(new ezcConsoleOption('', 'min-tokens', ezcConsoleInput::TYPE_INT, 70)); $input->registerOption(new ezcConsoleOption('', 'save-memory', ezcConsoleInput::TYPE_NONE, NULL, FALSE)); $input->registerOption(new ezcConsoleOption('', 'suffixes', ezcConsoleInput::TYPE_STRING, 'php', FALSE)); $input->registerOption(new ezcConsoleOption('', 'quiet', ezcConsoleInput::TYPE_NONE, NULL, FALSE)); $input->registerOption(new ezcConsoleOption('v', 'version', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE)); $input->registerOption(new ezcConsoleOption('', 'verbose', ezcConsoleInput::TYPE_NONE)); try { $input->process(); } catch (ezcConsoleOptionException $e) { print $e->getMessage() . PHP_EOL; exit(1); } if ($input->getOption('help')->value) { self::showHelp(); exit(0); } else { if ($input->getOption('version')->value) { self::printVersionString(); exit(0); } } $arguments = $input->getArguments(); $exclude = $input->getOption('exclude')->value; if (is_array($exclude) && count($exclude) == 1) { array_map('trim', explode(',', array_pop($exclude))); } $logPmd = $input->getOption('log-pmd')->value; $minLines = $input->getOption('min-lines')->value; $minTokens = $input->getOption('min-tokens')->value; $saveMemory = $input->getOption('save-memory')->value; $suffixes = array_map('trim', explode(',', $input->getOption('suffixes')->value)); $quiet = $input->getOption('quiet')->value; if ($input->getOption('verbose')->value !== FALSE) { $verbose = $output; } else { $verbose = NULL; } if (!empty($arguments)) { $facade = new File_Iterator_Facade(); $result = $facade->getFilesAsArray($arguments, $suffixes, array(), $exclude, TRUE); $files = $result['files']; $commonPath = $result['commonPath']; unset($result); } else { self::showHelp(); exit(1); } if (empty($files)) { self::showError('No files found to scan.' . PHP_EOL); } self::printVersionString(); if (!$saveMemory) { $strategy = new PHPCPD_Detector_Strategy_Default(); } else { $strategy = new PHPCPD_Detector_Strategy_SaveMemory(); } $detector = new PHPCPD_Detector($strategy, $verbose); $clones = $detector->copyPasteDetection($files, $minLines, $minTokens); $printer = new PHPCPD_TextUI_ResultPrinter(); $printer->printResult($clones, $commonPath, !$quiet); unset($printer); if ($logPmd) { $pmd = new PHPCPD_Log_XML_PMD($logPmd); $pmd->processClones($clones); unset($pmd); } if (count($clones) > 0) { exit(1); } }
/** * Helper to execute a lint check on generated code * * @param string $code Generated code to lint * @param \ezcConsoleInput $input CLI Options pased to app * * @return boolean */ protected function lintCode($code, $input) { $dsp = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w")); $php = $input->getOption('lint-php'); if ($php->value === false) { $binary = PHP_OS === 'WIN' ? 'C:\\php\\php.exe' : '/usr/bin/php'; } else { $binary = $php->value; } $process = proc_open($binary . ' -l', $dsp, $pipes); if (!is_resource($process)) { fwrite(STDERR, "Opening php binary for linting failed.\n"); exit(1); } fwrite($pipes[0], $code); fclose($pipes[0]); $stdout = stream_get_contents($pipes[1]); fclose($pipes[1]); $stderr = stream_get_contents($pipes[2]); fclose($pipes[2]); $rc = proc_close($process); if ($rc == 255) { fwrite(STDERR, "Syntax errors during lint:\n" . str_replace('in - on line', 'in generated code on line', $stderr) . "\n"); return false; } echo "Lint check of geneated code okay\n\n"; return true; }
/** * @return \ezcConsoleInput */ protected function setupInput() { $input = new \ezcConsoleInput(); $this->versionOption = $input->registerOption(new \ezcConsoleOption('v', 'version')); $this->versionOption->shorthelp = 'Prints the version and exits'; $this->versionOption->isHelpOption = TRUE; $this->helpOption = $input->registerOption(new \ezcConsoleOption('h', 'help')); $this->helpOption->isHelpOption = TRUE; $this->helpOption->shorthelp = 'Prints this usage information'; $input->registerOption(new \ezcConsoleOption('', 'cache', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Enable cache and set cache filename')); $this->outputOption = $input->registerOption(new \ezcConsoleOption('o', 'output', \ezcConsoleInput::TYPE_STRING, 'STDOUT', FALSE, 'Output file for generated code (default: STDOUT)')); $this->pharOption = $input->registerOption(new \ezcConsoleOption('p', 'phar', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Build a phar archive of directory contents', NULL, array(new \ezcConsoleOptionRule($input->getOption('o'))))); $input->registerOption(new \ezcConsoleOption('', 'all', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Add all files from src dir to phar', NULL, array(new \ezcConsoleOptionRule($input->getOption('p'))))); $input->registerOption(new \ezcConsoleOption('', 'alias', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Provide explicit internal alias filename for phar', NULL, array(new \ezcConsoleOptionRule($input->getOption('p'))))); $bzip2 = $input->registerOption(new \ezcConsoleOption('', 'bzip2', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Compress files phar with bzip2', NULL, array(new \ezcConsoleOptionRule($input->getOption('p'))))); $gzip = $input->registerOption(new \ezcConsoleOption('', 'gzip', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Compress files phar with gzip', NULL, array(new \ezcConsoleOptionRule($input->getOption('p'))), array(new \ezcConsoleOptionRule($bzip2)))); $bzip2->addExclusion(new \ezcConsoleOptionRule($gzip)); $input->registerOption(new \ezcConsoleOption('', 'key', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Keyfile to use for signing phar archive', NULL, array(new \ezcConsoleOptionRule($input->getOption('p'))))); $this->outputOption = $input->registerOption(new \ezcConsoleOption('', 'hash', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Force given hash algorithm (SHA-1, SHA-256 or SHA-512) (requires -p)', NULL, array(new \ezcConsoleOptionRule($input->getOption('p'))), array(new \ezcConsoleOptionRule($input->getOption('key'))))); $input->registerOption(new \ezcConsoleOption('i', 'include', \ezcConsoleInput::TYPE_STRING, '*.php', TRUE, 'File pattern to include (default: *.php)')); $input->registerOption(new \ezcConsoleOption('', 'blacklist', \ezcConsoleInput::TYPE_STRING, NULL, TRUE, 'Name pattern to exclude')); $input->registerOption(new \ezcConsoleOption('', 'whitelist', \ezcConsoleInput::TYPE_STRING, '*', TRUE, 'Name pattern to include (default: *)')); $input->registerOption(new \ezcConsoleOption('e', 'exclude', \ezcConsoleInput::TYPE_STRING, NULL, TRUE, 'File pattern to exclude')); $input->registerOption(new \ezcConsoleOption('b', 'basedir', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Basedir for filepaths')); $input->registerOption(new \ezcConsoleOption('t', 'template', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Path to code template to use')); $input->registerOption(new \ezcConsoleOption('', 'follow', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Enables following symbolic links', NULL, array(), array(new \ezcConsoleOptionRule($this->pharOption)))); $input->registerOption(new \ezcConsoleOption('', 'format', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Dateformat string for timestamp')); $input->registerOption(new \ezcConsoleOption('', 'linebreak', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Linebreak style (CR, CR/LF or LF)')); $input->registerOption(new \ezcConsoleOption('', 'indent', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'String used for indenting (default: 3 spaces)')); $this->lintOption = $input->registerOption(new \ezcConsoleOption('', 'lint', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Run lint on generated code')); $input->registerOption(new \ezcConsoleOption('', 'lint-php', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'PHP binary path for linting (default: /usr/bin/php or c:\\php\\php.exe)', NULL, array(new \ezcConsoleOptionRule($input->getOption('lint'))))); $compat = $input->registerOption(new \ezcConsoleOption('c', 'compat', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Generate PHP 5.2 compliant code')); $this->staticOption = $input->registerOption(new \ezcConsoleOption('s', 'static', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Build a static require file')); $input->registerOption(new \ezcConsoleOption('', 'tolerant', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Ignore Class Redeclarations in the same file')); $trusting = $input->registerOption(new \ezcConsoleOption('', 'trusting', \ezcConsoleInput::TYPE_NONE, TRUE, FALSE, 'Do not check mimetype of files prior to parsing')); $paranoid = $input->registerOption(new \ezcConsoleOption('', 'paranoid', \ezcConsoleInput::TYPE_NONE, FALSE, FALSE, 'Do check mimetype of files prior to parsing', NULL, array(), array(new \ezcConsoleOptionRule($trusting)))); $trusting->addExclusion(new \ezcConsoleOptionRule($paranoid)); $this->onceOption = $input->registerOption(new \ezcConsoleOption('', 'once', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Use require_once in static require mode', NULL, array(new \ezcConsoleOptionRule($input->getOption('s'))))); $input->registerOption(new \ezcConsoleOption('n', 'nolower', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Do not lowercase classnames for case insensitivity')); $input->registerOption(new \ezcConsoleOption('q', 'quiet', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Run in quiet mode, no output')); $input->registerOption(new \ezcConsoleOption('1', 'prepend', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Prepend autoloader to stack', NULL, array(), array(new \ezcConsoleOptionRule($compat)))); $input->registerOption(new \ezcConsoleOption('d', 'no-exception', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Disable exceptions on registration error')); $input->registerOption(new \ezcConsoleOption(NULL, 'var', \ezcConsoleInput::TYPE_STRING, array(), TRUE, 'Assign variable')); $input->argumentDefinition = new \ezcConsoleArguments(); $input->argumentDefinition[0] = new \ezcConsoleArgument("directory"); $input->argumentDefinition[0]->shorthelp = "The directory to process."; $input->argumentDefinition[0]->multiple = TRUE; return $input; }