예제 #1
0
 /**
  * @throws PHPMDViolationsException
  */
 public function run()
 {
     $this->outputHandler->setTitle('Checking code mess with PHPMD');
     $this->output->write($this->outputHandler->getTitle());
     $errors = [];
     foreach ($this->files as $file) {
         if (!preg_match($this->needle, $file)) {
             continue;
         }
         $processBuilder = new ProcessBuilder(array('php', 'bin/phpmd', $file, 'text', 'PmdRules.xml', '--minimumpriority', 1));
         $process = $processBuilder->getProcess();
         $process->run();
         if (false === $process->isSuccessful()) {
             $errors[] = $process->getOutput();
         }
     }
     $errors = array_filter($errors, function ($var) {
         return !is_null($var);
     });
     if ($errors) {
         $this->output->writeln(BadJobLogo::paint());
         throw new PHPMDViolationsException(implode('', $errors));
     }
     $this->output->writeln($this->outputHandler->getSuccessfulStepMessage());
 }
 /**
  * @throws InvalidCodingStandardException
  */
 public function run()
 {
     $this->outputHandler->setTitle('Checking code style with PHPCS');
     $this->output->write($this->outputHandler->getTitle());
     foreach ($this->files as $file) {
         if (!preg_match($this->neddle, $file)) {
             continue;
         }
         $oldPath = getcwd();
         $file = $oldPath . '/' . $file;
         chdir(__DIR__ . '/../../../../../../../');
         $processBuilder = new ProcessBuilder(array('php', 'bin/phpcs', '--standard=' . self::STANDARD . '', $file));
         /** @var Process $phpCs */
         $phpCs = $processBuilder->getProcess();
         $phpCs->run();
         if (false === $phpCs->isSuccessful()) {
             $this->outputHandler->setError($phpCs->getOutput());
             $this->output->writeln($this->outputHandler->getError());
             $this->output->writeln(BadJobLogo::paint());
             throw new InvalidCodingStandardException();
         }
         chdir($oldPath);
     }
     $this->output->writeln($this->outputHandler->getSuccessfulStepMessage());
 }
 /**
  * @throws PhpCsFixerException
  */
 public function run()
 {
     foreach ($this->levels as $level => $value) {
         if (true === $value) {
             $this->outputHandler->setTitle('Checking ' . strtoupper($level) . ' code style with PHP-CS-FIXER');
             $this->output->write($this->outputHandler->getTitle());
             $errors = array();
             foreach ($this->files as $file) {
                 $srcFile = preg_match($this->filesToAnalyze, $file);
                 if (!$srcFile) {
                     continue;
                 }
                 $processBuilder = new ProcessBuilder(array('php', 'bin/php-cs-fixer', '--dry-run', 'fix', $file, '--level=' . $level));
                 $phpCsFixer = $processBuilder->getProcess();
                 $phpCsFixer->run();
                 if (false === $phpCsFixer->isSuccessful()) {
                     $errors[] = $phpCsFixer->getOutput();
                 }
             }
             if ($errors) {
                 $this->output->writeln(BadJobLogo::paint());
                 throw new PhpCsFixerException(implode('', $errors));
             }
             $this->output->writeln($this->outputHandler->getSuccessfulStepMessage());
         }
     }
 }
예제 #4
0
 public function run()
 {
     $this->outputHandler->setTitle(sprintf('Checking json code with %s', strtoupper('jsonlint')));
     $this->output->write($this->outputHandler->getTitle());
     $errors = [];
     foreach ($this->files as $file) {
         if (!preg_match($this->needle, $file)) {
             continue;
         }
         $processBuilder = new ProcessBuilder(array('php', 'bin/jsonlint', $file));
         $process = $processBuilder->getProcess();
         $process->run();
         if (false === $process->isSuccessful()) {
             $errors[] = $process->getOutput();
         }
     }
     $errors = array_filter($errors, function ($var) {
         return !is_null($var);
     });
     if ($errors) {
         $this->output->writeln(BadJobLogo::paint());
         throw new JsonLintViolationsException(implode('', $errors));
     }
     $this->output->writeln($this->outputHandler->getSuccessfulStepMessage());
 }
예제 #5
0
 /**
  * @throws UnitTestsException
  */
 public function run()
 {
     $this->setTitle();
     $processBuilder = $this->phpUnitProcessBuilder->getProcessBuilder();
     $processBuilder->setTimeout(3600);
     $phpunit = $processBuilder->getProcess();
     $this->phpUnitProcessBuilder->executeProcess($phpunit, $this->output);
     if (!$phpunit->isSuccessful()) {
         $this->output->writeln(BadJobLogo::paint());
         throw new UnitTestsException();
     }
 }