.php_cs.dist 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_issets' => true,
  19. 'combine_consecutive_unsets' => true,
  20. // one should use PHPUnit methods to set up expected exception instead of annotations
  21. 'general_phpdoc_annotation_remove' => ['annotations' => ['expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp']],
  22. 'header_comment' => ['header' => $header],
  23. 'heredoc_to_nowdoc' => true,
  24. 'list_syntax' => ['syntax' => 'long'],
  25. 'method_argument_space' => ['ensure_fully_multiline' => true],
  26. 'no_extra_consecutive_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']],
  27. 'no_null_property_initialization' => true,
  28. 'no_short_echo_tag' => true,
  29. 'no_superfluous_elseif' => true,
  30. 'no_unneeded_curly_braces' => true,
  31. 'no_unneeded_final_method' => true,
  32. 'no_unreachable_default_argument_value' => true,
  33. 'no_useless_else' => true,
  34. 'no_useless_return' => true,
  35. 'ordered_class_elements' => true,
  36. 'ordered_imports' => true,
  37. 'php_unit_strict' => true,
  38. 'php_unit_test_class_requires_covers' => true,
  39. 'phpdoc_add_missing_param_annotation' => true,
  40. 'phpdoc_order' => true,
  41. 'phpdoc_types_order' => true,
  42. 'semicolon_after_instruction' => true,
  43. 'single_line_comment_style' => true,
  44. 'strict_comparison' => true,
  45. 'strict_param' => true,
  46. 'yoda_style' => true,
  47. ])
  48. ->setFinder(
  49. PhpCsFixer\Finder::create()
  50. ->exclude('tests/Fixtures')
  51. ->in(__DIR__)
  52. )
  53. ;
  54. // special handling of fabbot.io service if it's using too old PHP CS Fixer version
  55. try {
  56. PhpCsFixer\FixerFactory::create()
  57. ->registerBuiltInFixers()
  58. ->registerCustomFixers($config->getCustomFixers())
  59. ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()));
  60. } catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
  61. $config->setRules([]);
  62. } catch (UnexpectedValueException $e) {
  63. $config->setRules([]);
  64. }
  65. return $config;