.php_cs.dist 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. // HARD copy of .php-cs-fixer.dist.php file for fabbot.io compatibility for PHP CS Fixer v2
  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. ->exclude('tests/Fixtures')
  21. ->in(__DIR__)
  22. ->append([
  23. __DIR__.'/dev-tools/doc.php',
  24. __DIR__.'/php-cs-fixer',
  25. ])
  26. ;
  27. $config = new PhpCsFixer\Config();
  28. $config
  29. ->setRiskyAllowed(true)
  30. ->setRules([
  31. '@PHP56Migration' => true,
  32. '@PHPUnit75Migration:risky' => true,
  33. '@PhpCsFixer' => true,
  34. '@PhpCsFixer:risky' => true,
  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;