showUsage(); return self::SUCCESS; } if (in_array('-V', $_SERVER['argv']) || in_array('--version', $_SERVER['argv'])) { $this->showVersion(); return self::SUCCESS; } try { $settings = Settings::parseArguments($_SERVER['argv']); if ($settings->stdin) { $settings->addPaths(Settings::getPathsFromStdIn()); } if (empty($settings->paths)) { $this->showUsage(); return self::FAILED; } $manager = new Manager; $result = $manager->run($settings); if ($settings->ignoreFails) { return $result->hasSyntaxError() ? self::WITH_ERRORS : self::SUCCESS; } else { return $result->hasError() ? self::WITH_ERRORS : self::SUCCESS; } } catch (InvalidArgumentException $e) { echo "Invalid option {$e->getArgument()}", PHP_EOL, PHP_EOL; $this->showOptions(); return self::FAILED; } catch (Exception $e) { if (isset($settings) && $settings->format === Settings::FORMAT_JSON) { echo json_encode($e); } else { echo $e->getMessage(), PHP_EOL; } return self::FAILED; } catch (\Exception $e) { echo $e->getMessage(), PHP_EOL; return self::FAILED; } } /** * Outputs the options */ private function showOptions() { echo << Specify PHP-CGI executable to run (default: 'php'). -s, --short Set short_open_tag to On (default: Off). -a, --asp Set asp_tags to On (default: Off). -e Check only files with selected extensions separated by comma. (default: php,php3,php4,php5,phtml,phpt) -j Run jobs in parallel (default: 10). --exclude Exclude a file or directory. If you want exclude multiple items, use multiple exclude parameters. --colors Enable colors in console output. (disables auto detection of color support) --no-colors Disable colors in console output. --no-progress Disable progress in console output. --checkstyle Output results as Checkstyle XML. --json Output results as JSON string (requires PHP 5.4). --gitlab Output results for the GitLab Code Quality Widget (requires PHP 5.4). --blame Try to show git blame for row with error. --git Path to Git executable to show blame message (default: 'git'). --stdin Load files and folder to test from standard input. --ignore-fails Ignore failed tests. --show-deprecated Show deprecations (default: Off). --syntax-error-callback File with syntax error callback for ability to modify error -h, --help Print this help. -V, --version Display the application version HELP; } /** * Outputs the current version */ private function showVersion() { echo 'PHP Parallel Lint version ' . self::VERSION.PHP_EOL; } /** * Shows usage */ private function showUsage() { $this->showVersion(); echo <<showOptions(); } }