protected function execute(InputInterface $input, OutputInterface $output) { $this->outputHeading($output, 'PHP Lint on %s'); $files = $this->plugin->getFiles(Finder::create()->name('*.php')); if (count($files) === 0) { return $this->outputSkip($output); } $settings = new Settings(); $settings->addPaths($files); $manager = new Manager(); $result = $manager->run($settings); return $result->hasError() ? 1 : 0; }
/** * Check a single file for PHP syntax errors. * * @param string $file Path to the file to lint * @param OutputInterface $output * * @return int */ public function lintFile($file, OutputInterface $output) { $manager = new Manager(); $settings = new Settings(); $settings->addPaths([$file]); ob_start(); $result = $manager->run($settings); $buffer = ob_get_contents(); ob_end_clean(); if ($result->hasError()) { $output->writeln('<error>Syntax error was found in config.php after it was updated.</error>'); $output->writeln(['<error>Review the PHP Lint report for more details:</error>', '', $buffer]); } return $result->hasError() ? 1 : 0; }
public function _initialize() { if (!isset($this->config['lint'])) { throw new Exception('missing [lint] object in codeception.yml'); } /* Options: -p <php> Specify PHP-CGI executable to run (default: 'php'). -s, --short Set short_open_tag to On (default: Off). -e <ext> Check only files with selected extensions separated by comma. (default: php,php3,php4,php5,phtml) --exclude Exclude directory. If you want exclude multiple directories, use multiple exclude parameters. --ignore-fails Ignore failed tests. */ try { $settings = Settings::parseArguments($this->config['lint']); $manager = new PhpParallelLint\Manager(); $result = $manager->run($settings); $hasError = $result->hasError(); $result = json_decode(json_encode($result)); teamcity_console_logger(MessageTemplate::BlockStart('ParallelLintTeamcityReporter')); teamcity_console_logger(MessageTemplate::TestSuiteStart('Errors')); foreach ($result->errors as $index => $error) { $type = $error->type . "[{$index}]"; teamcity_console_logger(MessageTemplate::TestStart($type . ' ~ ' . $error->file)); teamcity_console_logger(MessageTemplate::TestFailed($error->normalizeMessage, $error->message)); teamcity_console_logger(MessageTemplate::TestEnd($error->file)); } teamcity_console_logger(MessageTemplate::TestSuiteEnd('Errors')); teamcity_console_logger(MessageTemplate::BlockStart('FilesWithSyntaxError')); foreach ($result->filesWithSyntaxError as $index => $value) { $type = $error->type . "[{$index}]"; teamcity_console_logger(MessageTemplate::Log("[{$index}] - {$value}")); } teamcity_console_logger(MessageTemplate::BlockEnd('FilesWithSyntaxError')); teamcity_console_logger(MessageTemplate::BlockStart('CheckedFiles')); foreach ($result->checkedFiles as $index => $value) { $type = $error->type . "[{$index}]"; teamcity_console_logger(MessageTemplate::Log("[{$index}] - {$value}")); } teamcity_console_logger(MessageTemplate::BlockEnd('CheckedFiles')); teamcity_console_logger(MessageTemplate::BlockStart('SkippedFiles')); foreach ($result->skippedFiles as $index => $value) { $type = $error->type . "[{$index}]"; teamcity_console_logger(MessageTemplate::Log("[{$index}] - {$value}")); } teamcity_console_logger(MessageTemplate::BlockEnd('SkippedFiles')); teamcity_console_logger(MessageTemplate::BlockEnd('ParallelLintTeamcityReporter')); } catch (Exception $e) { echo $e->getMessage(), PHP_EOL; die(255); } }
require $file; $autoloadFileFound = true; break; } } if (!$autoloadFileFound) { echo 'You need to set up the project dependencies using the following commands:' . PHP_EOL . 'curl -s http://getcomposer.org/installer | php' . PHP_EOL . 'php composer.phar install' . PHP_EOL; die(FAILED); } try { $settings = PhpParallelLint\Settings::parseArguments($_SERVER['argv']); if ($settings->json && PHP_VERSION_ID < 50400) { throw new \Exception('JSON output require PHP version 5.4 and newer.'); } if ($settings->stdin) { $settings->addPaths(PhpParallelLint\Settings::getPathsFromStdIn()); } if (empty($settings->paths)) { showUsage(); } $manager = new PhpParallelLint\Manager(); $result = $manager->run($settings); die($result->hasError() ? WITH_ERRORS : SUCCESS); } catch (PhpParallelLint\InvalidArgumentException $e) { echo "Invalid option {$e->getArgument()}" . PHP_EOL . PHP_EOL; showOptions(); die(FAILED); } catch (PhpParallelLint\Exception $e) { if ($settings->json) { echo json_encode($e); } else {