.php_cs.dist 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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', disabled, as we want to be able to run bootstrap file even on lower PHP version, to show nice message
  24. ])
  25. ;
  26. $config = new PhpCsFixer\Config();
  27. $config
  28. ->setRiskyAllowed(true)
  29. ->setRules([
  30. '@PHP71Migration:risky' => true,
  31. '@PHPUnit75Migration:risky' => true,
  32. '@PhpCsFixer' => true,
  33. '@PhpCsFixer:risky' => true,
  34. 'header_comment' => ['header' => $header],
  35. ])
  36. ->setFinder($finder)
  37. ;
  38. // special handling of fabbot.io service if it's using too old PHP CS Fixer version
  39. if (false !== getenv('FABBOT_IO')) {
  40. try {
  41. PhpCsFixer\FixerFactory::create()
  42. ->registerBuiltInFixers()
  43. ->registerCustomFixers($config->getCustomFixers())
  44. ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()))
  45. ;
  46. } catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
  47. $config->setRules([]);
  48. } catch (UnexpectedValueException $e) {
  49. $config->setRules([]);
  50. } catch (InvalidArgumentException $e) {
  51. $config->setRules([]);
  52. }
  53. }
  54. return $config;