.php-cs-fixer.dist.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. '@PHP71Migration' => true,
  34. '@PHP71Migration: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. 'modernize_strpos' => true, // needs PHP 8+ or polyfill
  41. ])
  42. ->setFinder($finder)
  43. ;
  44. // special handling of fabbot.io service if it's using too old PHP CS Fixer version
  45. if (false !== getenv('FABBOT_IO')) {
  46. try {
  47. PhpCsFixer\FixerFactory::create()
  48. ->registerBuiltInFixers()
  49. ->registerCustomFixers($config->getCustomFixers())
  50. ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()))
  51. ;
  52. } catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
  53. $config->setRules([]);
  54. } catch (UnexpectedValueException $e) {
  55. $config->setRules([]);
  56. } catch (InvalidArgumentException $e) {
  57. $config->setRules([]);
  58. }
  59. }
  60. return $config;