Ejemplo n.º 1
0
 /**
  * Make the default finder for SellerLabs projects.
  *
  * @return Finder
  */
 protected function makeFinder()
 {
     $directories = RootDirectories::getEnforceable();
     $found = [];
     $filesystem = new Filesystem();
     foreach ($directories as $directory) {
         if ($filesystem->exists($directory) && is_dir($directory)) {
             $found[] = $directory;
         }
     }
     return DefaultFinder::create()->in($found);
 }
Ejemplo n.º 2
0
 /**
  * Execute the command.
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return int|null
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $headerCommand = new HeaderCommand();
     $sortCommand = new UseSortCommand();
     $filesystem = new Filesystem();
     foreach (RootDirectories::getEnforceable() as $directory) {
         if ($filesystem->exists($directory) && is_dir($directory)) {
             $formatInput = ['path' => $directory];
             if ($input->getOption('dry-run')) {
                 $formatInput['--dry-run'] = true;
             }
             $output->writeln('<comment>' . $directory . '</comment>');
             $headerCommand->run(new ArrayInput($formatInput), $output);
             $sortCommand->run(new ArrayInput($formatInput), $output);
         }
     }
     return 0;
 }
Ejemplo n.º 3
0
 /**
  * Execute the command.
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return int
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $this->setupFormatters($output->getFormatter());
     $finder = new Finder();
     $phpcs = new CodeSniffer(0);
     $phpcsCli = new CLI();
     $phpcsCli->errorSeverity = PHPCS_DEFAULT_ERROR_SEV;
     $phpcsCli->warningSeverity = PHPCS_DEFAULT_WARN_SEV;
     $phpcsCli->dieOnUnknownArg = false;
     $phpcsCli->setCommandLineValues(['--colors', '-p', '--report=full']);
     $phpcs->setCli($phpcsCli);
     $existing = [];
     foreach (RootDirectories::getEnforceable() as $directory) {
         if (file_exists($directory) && is_dir($directory)) {
             $existing[] = $directory;
         }
     }
     $files = $finder->files()->in($existing)->notName('*Sniff.php')->ignoreUnreadableDirs()->ignoreDotFiles(true)->ignoreVCS(true)->name('*.php');
     $phpcs->reporting->startTiming();
     $phpcs->initStandard(Anchor::getDirectory());
     $files = array_keys(iterator_to_array($files->getIterator()));
     $processed = [];
     $withErrors = [];
     $withWarnings = [];
     foreach ($files as $file) {
         $done = $phpcs->processFile($file);
         if ($done->getErrorCount() > 0) {
             $output->write('E');
             $withErrors[] = $done;
             if ($done->getWarningCount() > 0) {
                 $withWarnings[] = $done;
             }
         } elseif ($done->getWarningCount() > 0) {
             $output->write('W');
             $withWarnings[] = $done;
         } else {
             $output->write('.');
         }
         $processed[] = $done;
     }
     $this->renderSummary($withErrors, $withWarnings, $output);
 }
Ejemplo n.º 4
0
 /**
  * Execute the command.
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return int
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $filesystem = new Filesystem();
     $discouraged = RootDirectories::getDiscouraged();
     $found = [];
     foreach ($discouraged as $directory => $comment) {
         if ($filesystem->exists($directory) && is_dir($directory)) {
             $found[] = [$directory, $comment];
         }
     }
     if (count($found) == 0) {
         $output->writeln('<fg=green>No issues found.</fg=green>');
         return 0;
     }
     $output->writeln('The following issues where found:');
     $table = new Table($output);
     $table->setHeaders(['Directory', 'Comment']);
     $table->setRows($found);
     $table->render();
     return 1;
 }