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; }