.php-cs-fixer.dist.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. require_once './vendor-bin/cs-fixer/vendor/autoload.php';
  8. use Nextcloud\CodingStandard\Config;
  9. use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
  10. $config = new Config();
  11. $config
  12. ->setParallelConfig(ParallelConfigFactory::detect())
  13. ->getFinder()
  14. ->exclude('config')
  15. ->exclude('3rdparty')
  16. ->exclude('build/stubs')
  17. ->exclude('composer')
  18. ->in(__DIR__);
  19. $ignoredEntries = shell_exec('git status --porcelain --ignored ' . escapeshellarg(__DIR__));
  20. $ignoredEntries = explode("\n", $ignoredEntries);
  21. $ignoredEntries = array_filter($ignoredEntries, static fn (string $line) => str_starts_with($line, '!! '));
  22. $ignoredEntries = array_map(static fn (string $line) => substr($line, 3), $ignoredEntries);
  23. $ignoredEntries = array_values($ignoredEntries);
  24. foreach ($ignoredEntries as $ignoredEntry) {
  25. if (str_ends_with($ignoredEntry, '/')) {
  26. $config->getFinder()->exclude($ignoredEntry);
  27. } else {
  28. $config->getFinder()->notPath($ignoredEntry);
  29. }
  30. }
  31. return $config;