.php_cs.dist 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. '@PHPUnit60Migration:risky' => true,
  14. '@Symfony' => true,
  15. '@Symfony:risky' => true,
  16. 'align_multiline_comment' => true,
  17. 'array_syntax' => ['syntax' => 'short'],
  18. 'blank_line_before_statement' => true,
  19. 'combine_consecutive_issets' => true,
  20. 'combine_consecutive_unsets' => true,
  21. 'compact_nullable_typehint' => true,
  22. 'escape_implicit_backslashes' => true,
  23. 'explicit_indirect_variable' => true,
  24. 'explicit_string_variable' => true,
  25. 'final_internal_class' => true,
  26. 'header_comment' => ['header' => $header],
  27. 'heredoc_to_nowdoc' => true,
  28. 'list_syntax' => ['syntax' => 'long'],
  29. 'method_chaining_indentation' => true,
  30. 'method_argument_space' => ['ensure_fully_multiline' => true],
  31. 'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']],
  32. 'no_null_property_initialization' => true,
  33. 'no_short_echo_tag' => true,
  34. 'no_superfluous_elseif' => true,
  35. 'no_unneeded_curly_braces' => true,
  36. 'no_unneeded_final_method' => true,
  37. 'no_unreachable_default_argument_value' => true,
  38. 'no_useless_else' => true,
  39. 'no_useless_return' => true,
  40. 'ordered_class_elements' => true,
  41. 'ordered_imports' => true,
  42. 'php_unit_strict' => true,
  43. 'php_unit_test_annotation' => true,
  44. 'php_unit_test_class_requires_covers' => true,
  45. 'phpdoc_add_missing_param_annotation' => true,
  46. 'phpdoc_order' => true,
  47. 'phpdoc_types_order' => true,
  48. 'semicolon_after_instruction' => true,
  49. 'single_line_comment_style' => true,
  50. 'strict_comparison' => true,
  51. 'strict_param' => true,
  52. 'yoda_style' => true,
  53. ])
  54. ->setFinder(
  55. PhpCsFixer\Finder::create()
  56. ->exclude('tests/Fixtures')
  57. ->in(__DIR__)
  58. )
  59. ;
  60. // special handling of fabbot.io service if it's using too old PHP CS Fixer version
  61. try {
  62. PhpCsFixer\FixerFactory::create()
  63. ->registerBuiltInFixers()
  64. ->registerCustomFixers($config->getCustomFixers())
  65. ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()));
  66. } catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
  67. $config->setRules([]);
  68. } catch (UnexpectedValueException $e) {
  69. $config->setRules([]);
  70. } catch (InvalidArgumentException $e) {
  71. $config->setRules([]);
  72. }
  73. return $config;