.php-cs-fixer.dist.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. '@PHPUnit75Migration: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. 'use_arrow_functions' => false, // TODO switch on when # of PR's is lower
  43. ])
  44. ->setFinder($finder)
  45. ;
  46. // special handling of fabbot.io service if it's using too old PHP CS Fixer version
  47. if (false !== getenv('FABBOT_IO')) {
  48. try {
  49. PhpCsFixer\FixerFactory::create()
  50. ->registerBuiltInFixers()
  51. ->registerCustomFixers($config->getCustomFixers())
  52. ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()))
  53. ;
  54. } catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
  55. $config->setRules([]);
  56. } catch (UnexpectedValueException $e) {
  57. $config->setRules([]);
  58. } catch (InvalidArgumentException $e) {
  59. $config->setRules([]);
  60. }
  61. }
  62. return $config;