예제 #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     try {
         $settings = new PhpParallelLint\Settings();
         //$output->writeln("Hola");
         if ($input->hasArgument("directory")) {
             $settings->paths = $input->getArgument("directory");
         }
         if ($input->hasOption("exclude")) {
             $settings->excluded = $input->getOption("exclude");
         }
         if ($input->hasOption("extension")) {
             $settings->extensions = $input->getOption("extension");
         }
         if ($input->hasOption("number-jobs")) {
             $settings->parallelJobs = $input->getOption("number-jobs");
         }
         if ($input->hasOption("no-colors")) {
             $settings->colors = false;
         }
         $manager = new PhpParallelLint\Manager();
         $result = $manager->run($settings);
     } catch (Exception $e) {
     }
 }
 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);
     }
 }
예제 #3
0
 /**
  * {@inheritDoc}
  */
 public function run(OutputInterface $output)
 {
     // Run the linter.
     $this->linter = new Linter\Manager();
     $this->linter->setOutput(Output\Output::create($output));
     $result = $this->linter->run($this->getLinterSettings());
     // Throw an exception when syntax errors were found.
     if ($result->hasError()) {
         throw new TaskRuntimeException($this->getName(), 'The linter identified syntax errors.');
     }
 }
예제 #4
0
 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;
 }
예제 #5
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;
 }
예제 #6
0
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 {
        echo $e->getMessage(), PHP_EOL;
    }
    die(FAILED);
} catch (Exception $e) {
    echo $e->getMessage(), PHP_EOL;