.php-cs-fixer.dist.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /*
  3. * This file is part of PHP CS Fixer.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  7. *
  8. * This source file is subject to the MIT license that is bundled
  9. * with this source code in the file LICENSE.
  10. */
  11. $header = <<<'EOF'
  12. This file is part of PHP CS Fixer.
  13. (c) Fabien Potencier <fabien@symfony.com>
  14. Dariusz Rumiński <dariusz.ruminski@gmail.com>
  15. This source file is subject to the MIT license that is bundled
  16. with this source code in the file LICENSE.
  17. EOF;
  18. $finder = PhpCsFixer\Finder::create()
  19. ->exclude('tests/Fixtures')
  20. ->in(__DIR__)
  21. ->append([
  22. __DIR__.'/dev-tools/doc.php',
  23. __DIR__.'/php-cs-fixer',
  24. ])
  25. ;
  26. $config = new PhpCsFixer\Config();
  27. $config
  28. ->setRiskyAllowed(true)
  29. ->setRules([
  30. '@PHP56Migration' => true,
  31. '@PHPUnit75Migration:risky' => true,
  32. '@PhpCsFixer' => true,
  33. '@PhpCsFixer:risky' => true,
  34. 'header_comment' => ['header' => $header],
  35. 'list_syntax' => ['syntax' => 'long'],
  36. ])
  37. ->setFinder($finder)
  38. ;
  39. // special handling of fabbot.io service if it's using too old PHP CS Fixer version
  40. if (false !== getenv('FABBOT_IO')) {
  41. try {
  42. PhpCsFixer\FixerFactory::create()
  43. ->registerBuiltInFixers()
  44. ->registerCustomFixers($config->getCustomFixers())
  45. ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()))
  46. ;
  47. } catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
  48. $config->setRules([]);
  49. } catch (UnexpectedValueException $e) {
  50. $config->setRules([]);
  51. } catch (InvalidArgumentException $e) {
  52. $config->setRules([]);
  53. }
  54. }
  55. return $config;