/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $fileInput = trim($input->getArgument('file')); $pathInfoFile = pathinfo(realpath($fileInput)); $file = new File('', realpath($fileInput), $pathInfoFile['dirname']); $fileCollection = new FileCollection(); $fileCollection = $fileCollection->append($file); $reporter = new Reporter($output, 1); $review = new StaticReview($reporter); $review->addReview(new PhpCsFixerReview(self::AUTO_ADD_GIT)); // Review the staged files. $review->files($fileCollection); // Check if any matching issues were found. if ($reporter->hasIssues()) { $reporter->displayReport(); } if ($reporter->hasIssueLevel(Issue::LEVEL_ERROR)) { $io->error('✘ Please fix the errors above.'); exit(1); } else { $io->success('✔ Looking good.'); exit(0); } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $git = new GitVersionControl(); $stagedFiles = $git->getStagedFiles(); $projectBase = $git->getProjectBase(); $reporter = new Reporter($output, count($stagedFiles)); $review = new StaticReview($reporter); $review->addReview(new ComposerLockReview())->addReview(new ComposerLintReview())->addReview(new PhpLintReview())->addReview(new PhpStopWordsReview())->addReview(new JsStopWordsReview())->addReview(new EsLintReview(self::AUTO_ADD_GIT))->addReview(new YmlLintReview())->addReview(new JsonLintReview())->addReview(new XmlLintReview())->addReview(new GitConflictReview()); // -------------------------------------------------------- // Front Dev profile // -------------------------------------------------------- /*$review->addReview(new ScssLintReview()) ->addReview(new SassConvertFixerReview(self::AUTO_ADD_GIT));*/ // -------------------------------------------------------- // Dev PHP profile // -------------------------------------------------------- $phpCodeSniffer = new PhpCodeSnifferReview(); $phpCodeSniffer->setOption('standard', 'Pear'); $phpCodeSniffer->setOption('sniffs', 'PEAR.Commenting.FunctionComment'); $review->addReview(new PhpCPDReview())->addReview(new PhpMDReview())->addReview($phpCodeSniffer); // -------------------------------------------------------- $review->files($stagedFiles); $reporter->displayReport(); $testingReporter = new Reporter($output, 0); // -------------------------------------------------------- // Dev PHP profile // -------------------------------------------------------- if (!$reporter->hasIssueLevel(Issue::LEVEL_ERROR) && count($stagedFiles) > 0) { $testingReview = new TestingReview($testingReporter); if ($input->getOption('phpunit')) { $testingReview->addReview(new PhpUnitReview($input->getOption('phpunit-bin-path'), $input->getOption('phpunit-conf'), $projectBase)); } $testingReview->review(); $testingReporter->displayReport(); } // -------------------------------------------------------- if ($reporter->hasIssueLevel(Issue::LEVEL_ERROR) || $testingReporter->hasIssueLevel(Issue::LEVEL_ERROR)) { $io->error('✘ Please fix the errors above or use --no-verify.'); exit(1); } elseif ($reporter->hasIssueLevel(Issue::LEVEL_WARNING) || $testingReporter->hasIssueLevel(Issue::LEVEL_WARNING)) { $io->note('Try to fix warnings !'); } else { $io->success('✔ Looking good.'); } exit(0); }