.php-cs-fixer.dist.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. ->exclude('tests/Fixtures')
  21. ->in(__DIR__)
  22. ->append([
  23. __DIR__.'/dev-tools/doc.php',
  24. // __DIR__.'/php-cs-fixer', disabled, as we want to be able to run bootstrap file even on lower PHP version, to show nice message
  25. __FILE__,
  26. ])
  27. ;
  28. $config = new PhpCsFixer\Config();
  29. $config
  30. ->setRiskyAllowed(true)
  31. ->setRules([
  32. '@PHP71Migration' => true,
  33. '@PHP71Migration:risky' => true,
  34. '@PHPUnit75Migration:risky' => true,
  35. '@PhpCsFixer' => true,
  36. '@PhpCsFixer:risky' => true,
  37. 'general_phpdoc_annotation_remove' => ['annotations' => ['expectedDeprecation']], // one should use PHPUnit built-in method instead
  38. 'header_comment' => ['header' => $header],
  39. ])
  40. ->setFinder($finder)
  41. ;
  42. // special handling of fabbot.io service if it's using too old PHP CS Fixer version
  43. if (false !== getenv('FABBOT_IO')) {
  44. try {
  45. PhpCsFixer\FixerFactory::create()
  46. ->registerBuiltInFixers()
  47. ->registerCustomFixers($config->getCustomFixers())
  48. ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()))
  49. ;
  50. } catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
  51. $config->setRules([]);
  52. } catch (UnexpectedValueException $e) {
  53. $config->setRules([]);
  54. } catch (InvalidArgumentException $e) {
  55. $config->setRules([]);
  56. }
  57. }
  58. return $config;