/** * Build a Symfony2 Finder instance that searches all included paths for files. * * The local config instance will be queried for included and excluded files and the Finder will be populated with * them. * * @return Finder */ protected function buildFinder() { $finder = new Finder(); $finder->in($this->config->getIncludedPaths())->notPath('/vendor/')->files(); foreach ($this->config->getExcludedPaths() as $excluded) { $finder->notPath($excluded); } return $finder; }
/** * Determine the superfluous authors from the passed arrays. * * @param array $mentionedAuthors The author list containing the current state. * * @param array $wantedAuthors The author list containing the desired state. * * @param string $path The path to relate to. * * @return array */ private function determineSuperfluous($mentionedAuthors, $wantedAuthors, $path) { $superfluous = array(); foreach (array_diff_key($mentionedAuthors, $wantedAuthors) as $key => $author) { if (!$this->config->isCopyLeftAuthor($author, $path)) { $superfluous[$key] = $author; } } return $superfluous; }
/** * {@inheritDoc} * * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ protected function execute(InputInterface $input, OutputInterface $output) { $error = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output; if (!($input->getOption('php-files') || $input->getOption('composer') || $input->getOption('bower') || $input->getOption('packages'))) { $error->writeln('<error>You must select at least one validation to run!</error>'); $error->writeln('check-author.php [--php-files] [--composer] [--bower] [--packages]'); return 1; } $configFile = $input->getOption('config'); $defaultConfig = getcwd() . '/.check-author.yml'; if (!$configFile && is_file($defaultConfig)) { $configFile = $defaultConfig; } $config = new Config($configFile); $config->ignoreAuthors($input->getOption('ignore'))->excludePaths($input->getOption('exclude'))->includePaths(array_filter(array_map(function ($arg) { return realpath($arg); }, $input->getArgument('include')))); $diff = $input->getOption('diff'); $extractors = $this->createSourceExtractors($input, $error, $config); $gitExtractor = new GitAuthorExtractor($config, $error); $comparator = new AuthorListComparator($config, $error); $comparator->shallGeneratePatches($diff); $failed = $this->handleExtractors($extractors, $gitExtractor, $comparator); if ($failed && $diff) { $output->writeln($comparator->getPatchSet()); } return $failed ? 1 : 0; }