.php_cs.dist 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. $finder = PhpCsFixer\Finder::create()
  10. ->exclude('tests/Fixtures')
  11. ->in(__DIR__)
  12. ;
  13. $config = PhpCsFixer\Config::create()
  14. ->setRiskyAllowed(true)
  15. ->setRules([
  16. '@PHP56Migration' => true,
  17. '@PHPUnit60Migration:risky' => true,
  18. '@Symfony' => true,
  19. '@Symfony:risky' => true,
  20. 'align_multiline_comment' => true,
  21. 'array_indentation' => true,
  22. 'array_syntax' => ['syntax' => 'short'],
  23. 'blank_line_before_statement' => true,
  24. 'combine_consecutive_issets' => true,
  25. 'combine_consecutive_unsets' => true,
  26. 'comment_to_phpdoc' => true,
  27. 'compact_nullable_typehint' => true,
  28. 'escape_implicit_backslashes' => true,
  29. 'explicit_indirect_variable' => true,
  30. 'explicit_string_variable' => true,
  31. 'final_internal_class' => true,
  32. 'fully_qualified_strict_types' => true,
  33. 'function_to_constant' => ['functions' => ['get_class', 'get_called_class', 'php_sapi_name', 'phpversion', 'pi']],
  34. 'header_comment' => ['header' => $header],
  35. 'heredoc_to_nowdoc' => true,
  36. 'list_syntax' => ['syntax' => 'long'],
  37. 'logical_operators' => true,
  38. 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
  39. 'method_chaining_indentation' => true,
  40. 'multiline_comment_opening_closing' => true,
  41. // TODO: remove at 2.13, as it's part of @Symfony ruleset since 2.13
  42. 'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'],
  43. 'no_alternative_syntax' => true,
  44. 'no_binary_string' => true,
  45. 'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']],
  46. 'no_null_property_initialization' => true,
  47. 'no_short_echo_tag' => true,
  48. 'no_superfluous_elseif' => true,
  49. 'no_unneeded_curly_braces' => true,
  50. 'no_unneeded_final_method' => true,
  51. 'no_unreachable_default_argument_value' => true,
  52. 'no_unset_on_property' => true,
  53. 'no_useless_else' => true,
  54. 'no_useless_return' => true,
  55. 'ordered_class_elements' => true,
  56. 'ordered_imports' => true,
  57. 'php_unit_internal_class' => true,
  58. 'php_unit_ordered_covers' => true,
  59. 'php_unit_set_up_tear_down_visibility' => true,
  60. 'php_unit_strict' => true,
  61. 'php_unit_test_annotation' => true,
  62. 'php_unit_test_case_static_method_calls' => ['call_type' => 'this'],
  63. 'php_unit_test_class_requires_covers' => true,
  64. 'phpdoc_add_missing_param_annotation' => true,
  65. 'phpdoc_order' => true,
  66. 'phpdoc_trim_consecutive_blank_line_separation' => true,
  67. 'phpdoc_types_order' => true,
  68. 'return_assignment' => true,
  69. 'semicolon_after_instruction' => true,
  70. 'single_line_comment_style' => true,
  71. 'strict_comparison' => true,
  72. 'strict_param' => true,
  73. 'string_line_ending' => true,
  74. 'yoda_style' => true,
  75. ])
  76. ->setFinder($finder)
  77. ;
  78. // special handling of fabbot.io service if it's using too old PHP CS Fixer version
  79. if (false !== getenv('FABBOT_IO')) {
  80. try {
  81. PhpCsFixer\FixerFactory::create()
  82. ->registerBuiltInFixers()
  83. ->registerCustomFixers($config->getCustomFixers())
  84. ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()));
  85. } catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
  86. $config->setRules([]);
  87. } catch (UnexpectedValueException $e) {
  88. $config->setRules([]);
  89. } catch (InvalidArgumentException $e) {
  90. $config->setRules([]);
  91. }
  92. }
  93. return $config;