.php_cs.dist 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. 'general_phpdoc_annotation_remove' => ['annotations' => ['expectedDeprecation']],
  35. 'header_comment' => ['header' => $header],
  36. 'list_syntax' => ['syntax' => 'long'],
  37. ])
  38. ->setFinder($finder)
  39. ;
  40. // special handling of fabbot.io service if it's using too old PHP CS Fixer version
  41. if (false !== getenv('FABBOT_IO')) {
  42. try {
  43. PhpCsFixer\FixerFactory::create()
  44. ->registerBuiltInFixers()
  45. ->registerCustomFixers($config->getCustomFixers())
  46. ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()))
  47. ;
  48. } catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
  49. $config->setRules([]);
  50. } catch (UnexpectedValueException $e) {
  51. $config->setRules([]);
  52. } catch (InvalidArgumentException $e) {
  53. $config->setRules([]);
  54. }
  55. }
  56. return $config;