.php-cs-fixer.dist.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of PHP CS Fixer.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  8. *
  9. * This source file is subject to the MIT license that is bundled
  10. * with this source code in the file LICENSE.
  11. */
  12. $header = <<<'EOF'
  13. This file is part of PHP CS Fixer.
  14. (c) Fabien Potencier <fabien@symfony.com>
  15. Dariusz Rumiński <dariusz.ruminski@gmail.com>
  16. This source file is subject to the MIT license that is bundled
  17. with this source code in the file LICENSE.
  18. EOF;
  19. $finder = PhpCsFixer\Finder::create()
  20. ->ignoreDotFiles(false)
  21. ->ignoreVCSIgnored(true)
  22. ->exclude('tests/Fixtures')
  23. ->in(__DIR__)
  24. ->append([
  25. __DIR__.'/dev-tools/doc.php',
  26. // __DIR__.'/php-cs-fixer', disabled, as we want to be able to run bootstrap file even on lower PHP version, to show nice message
  27. ])
  28. ;
  29. $config = new PhpCsFixer\Config();
  30. $config
  31. ->setRiskyAllowed(true)
  32. ->setRules([
  33. '@PHP74Migration' => true,
  34. '@PHP74Migration:risky' => true,
  35. '@PHPUnit100Migration:risky' => true,
  36. '@PhpCsFixer' => true,
  37. '@PhpCsFixer:risky' => true,
  38. 'general_phpdoc_annotation_remove' => ['annotations' => ['expectedDeprecation']], // one should use PHPUnit built-in method instead
  39. 'header_comment' => ['header' => $header],
  40. 'heredoc_indentation' => false, // TODO switch on when # of PR's is lower
  41. 'modernize_strpos' => true, // needs PHP 8+ or polyfill
  42. 'no_useless_concat_operator' => false, // TODO switch back on when the `src/Console/Application.php` no longer needs the concat
  43. 'use_arrow_functions' => false, // TODO switch on when # of PR's is lower
  44. ])
  45. ->setFinder($finder)
  46. ;
  47. // special handling of fabbot.io service if it's using too old PHP CS Fixer version
  48. if (false !== getenv('FABBOT_IO')) {
  49. try {
  50. PhpCsFixer\FixerFactory::create()
  51. ->registerBuiltInFixers()
  52. ->registerCustomFixers($config->getCustomFixers())
  53. ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()))
  54. ;
  55. } catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
  56. $config->setRules([]);
  57. } catch (UnexpectedValueException $e) {
  58. $config->setRules([]);
  59. } catch (InvalidArgumentException $e) {
  60. $config->setRules([]);
  61. }
  62. }
  63. return $config;