.php_cs.dist 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. $header = <<<'EOF'
  3. This file is part of PHP CS Fixer.
  4. (c) Fabien Potencier <fabien@symfony.com>
  5. Dariusz Rumiński <dariusz.ruminski@gmail.com>
  6. This source file is subject to the MIT license that is bundled
  7. with this source code in the file LICENSE.
  8. EOF;
  9. $config = PhpCsFixer\Config::create()
  10. ->setRiskyAllowed(true)
  11. ->setRules([
  12. '@PHP56Migration' => true,
  13. '@Symfony' => true,
  14. '@Symfony:risky' => true,
  15. 'align_multiline_comment' => true,
  16. 'array_syntax' => ['syntax' => 'short'],
  17. 'blank_line_before_statement' => true,
  18. 'combine_consecutive_unsets' => true,
  19. // one should use PHPUnit methods to set up expected exception instead of annotations
  20. 'general_phpdoc_annotation_remove' => ['annotations' => ['expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp']],
  21. 'header_comment' => ['header' => $header],
  22. 'heredoc_to_nowdoc' => true,
  23. 'list_syntax' => ['syntax' => 'long'],
  24. 'method_argument_space' => ['ensure_fully_multiline' => true],
  25. 'no_extra_consecutive_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']],
  26. 'no_null_property_initialization' => true,
  27. 'no_short_echo_tag' => true,
  28. 'no_unreachable_default_argument_value' => true,
  29. 'no_useless_else' => true,
  30. 'no_useless_return' => true,
  31. 'ordered_class_elements' => true,
  32. 'ordered_imports' => true,
  33. 'php_unit_strict' => true,
  34. 'php_unit_test_class_requires_covers' => true,
  35. 'phpdoc_add_missing_param_annotation' => true,
  36. 'phpdoc_order' => true,
  37. 'phpdoc_types_order' => true,
  38. 'semicolon_after_instruction' => true,
  39. 'single_line_comment_style' => true,
  40. 'strict_comparison' => true,
  41. 'strict_param' => true,
  42. ])
  43. ->setFinder(
  44. PhpCsFixer\Finder::create()
  45. ->exclude('tests/Fixtures')
  46. ->in(__DIR__)
  47. )
  48. ;
  49. // special handling of fabbot.io service if it's using too old PHP CS Fixer version
  50. try {
  51. PhpCsFixer\FixerFactory::create()
  52. ->registerBuiltInFixers()
  53. ->registerCustomFixers($config->getCustomFixers())
  54. ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()));
  55. } catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
  56. $config->setRules([]);
  57. }
  58. return $config;