.php_cs.common.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. // Share common rules between non-test and test files
  3. return [
  4. // PSR12 from https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/4943
  5. '@PSR2' => true,
  6. 'blank_line_after_opening_tag' => true,
  7. 'braces' => [
  8. // Not-yet-implemented
  9. // 'allow_single_line_anonymous_class_with_empty_body' => true,
  10. ],
  11. 'compact_nullable_typehint' => true,
  12. 'declare_equal_normalize' => true,
  13. 'lowercase_cast' => true,
  14. 'lowercase_static_reference' => true,
  15. 'new_with_braces' => true,
  16. 'no_blank_lines_after_class_opening' => true,
  17. 'no_leading_import_slash' => true,
  18. 'no_whitespace_in_blank_line' => true,
  19. 'ordered_class_elements' => [
  20. 'order' => [
  21. 'use_trait',
  22. ],
  23. ],
  24. 'ordered_imports' => [
  25. 'imports_order' => [
  26. 'class',
  27. 'function',
  28. 'const',
  29. ],
  30. 'sort_algorithm' => 'alpha',
  31. ],
  32. 'return_type_declaration' => true,
  33. 'short_scalar_cast' => true,
  34. 'single_blank_line_before_namespace' => true,
  35. 'single_trait_insert_per_statement' => true,
  36. 'ternary_operator_spaces' => true,
  37. 'visibility_required' => [
  38. 'elements' => [
  39. 'const',
  40. 'method',
  41. 'property',
  42. ],
  43. ],
  44. // Further quality-of-life improvements
  45. 'array_syntax' => [
  46. 'syntax' => 'short',
  47. ],
  48. 'concat_space' => [
  49. 'spacing' => 'one',
  50. ],
  51. 'fully_qualified_strict_types' => true,
  52. 'native_function_invocation' => [
  53. 'include' => [],
  54. 'strict' => true,
  55. ],
  56. 'no_unused_imports' => true,
  57. 'single_quote' => true,
  58. 'space_after_semicolon' => true,
  59. 'trailing_comma_in_multiline_array' => true,
  60. 'trim_array_spaces' => true,
  61. 'unary_operator_spaces' => true,
  62. 'whitespace_after_comma_in_array' => true,
  63. ];