.php_cs.dist 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. $finder = PhpCsFixer\Finder::create()
  3. ->notName('pclzip.lib.php')
  4. ->notName('OLERead.php')
  5. ->in('samples')
  6. ->in('src')
  7. ->in('tests');
  8. return PhpCsFixer\Config::create()
  9. ->setRiskyAllowed(true)
  10. ->setFinder($finder)
  11. ->setRules(array(
  12. 'array_syntax' => array('syntax' => 'long'),
  13. 'binary_operator_spaces' => array('align_double_arrow' => true),
  14. 'blank_line_after_namespace' => true,
  15. 'blank_line_after_opening_tag' => false,
  16. 'blank_line_before_return' => true,
  17. 'braces' => true,
  18. 'cast_spaces' => true,
  19. 'class_definition' => true,
  20. 'class_keyword_remove' => false, // ::class keyword gives us beter support in IDE
  21. 'combine_consecutive_unsets' => true,
  22. 'concat_space' => array('spacing' => 'one'),
  23. 'declare_equal_normalize' => true,
  24. 'declare_strict_types' => false, // Too early to adopt strict types
  25. 'dir_constant' => true,
  26. 'elseif' => true,
  27. 'encoding' => true,
  28. 'ereg_to_preg' => true,
  29. 'full_opening_tag' => true,
  30. 'function_declaration' => true,
  31. 'function_typehint_space' => true,
  32. 'general_phpdoc_annotation_remove' => false, // No use for that
  33. 'hash_to_slash_comment' => true,
  34. 'header_comment' => false, // We don't use common header in all our files
  35. 'heredoc_to_nowdoc' => false, // Not sure about this one
  36. 'is_null' => false, // Risky
  37. 'include' => true,
  38. 'indentation_type' => true,
  39. 'line_ending' => true,
  40. 'linebreak_after_opening_tag' => true,
  41. 'lowercase_cast' => true,
  42. 'lowercase_constants' => true,
  43. 'lowercase_keywords' => true,
  44. 'mb_str_functions' => false, // No, too dangerous to change that
  45. 'method_argument_space' => true,
  46. 'method_separation' => true,
  47. 'modernize_types_casting' => true,
  48. 'native_function_casing' => true,
  49. 'native_function_invocation'=> false, // This is risky and seems to be micro-optimization that make code uglier so not worth it, at least for now
  50. 'new_with_braces' => true,
  51. 'no_alias_functions' => true,
  52. 'no_blank_lines_after_class_opening' => true,
  53. 'no_blank_lines_after_phpdoc' => true,
  54. 'no_blank_lines_before_namespace' => false, // we want 1 blank line before namespace
  55. 'no_closing_tag' => true,
  56. 'no_empty_comment' => true,
  57. 'no_empty_phpdoc' => true,
  58. 'no_empty_statement' => true,
  59. 'no_extra_consecutive_blank_lines' => array('break', 'continue', 'extra', 'return', 'throw', 'use', 'useTrait', 'curly_brace_block', 'parenthesis_brace_block', 'square_brace_block'),
  60. 'no_leading_import_slash' => true,
  61. 'no_leading_namespace_whitespace' => true,
  62. 'no_mixed_echo_print' => true,
  63. 'no_multiline_whitespace_around_double_arrow' => true,
  64. 'no_multiline_whitespace_before_semicolons' => true,
  65. 'no_php4_constructor' => true,
  66. 'no_short_bool_cast' => true,
  67. 'no_short_echo_tag' => true,
  68. 'no_singleline_whitespace_before_semicolons' => true,
  69. 'no_spaces_after_function_name' => true,
  70. 'no_spaces_around_offset' => true,
  71. 'no_spaces_inside_parenthesis' => true,
  72. 'no_trailing_comma_in_list_call' => true,
  73. 'no_trailing_comma_in_singleline_array' => true,
  74. 'no_trailing_whitespace' => true,
  75. 'no_trailing_whitespace_in_comment' => true,
  76. 'no_unneeded_control_parentheses' => true,
  77. 'no_unreachable_default_argument_value' => true,
  78. 'no_unused_imports' => true,
  79. 'no_useless_else' => true,
  80. 'no_useless_return' => true,
  81. 'no_whitespace_before_comma_in_array' => true,
  82. 'no_whitespace_in_blank_line' => true,
  83. 'normalize_index_brace' => true,
  84. 'not_operator_with_space' => false, // No we prefer to keep '!' without spaces
  85. 'not_operator_with_successor_space' => false, // idem
  86. 'object_operator_without_whitespace' => true,
  87. 'ordered_class_elements' => false, // We prefer to keep some freedom
  88. 'ordered_imports' => true,
  89. 'php_unit_construct' => true,
  90. 'php_unit_dedicate_assert' => true,
  91. 'php_unit_fqcn_annotation' => true,
  92. 'php_unit_strict' => false, // We sometime actually need assertEquals
  93. 'phpdoc_add_missing_param_annotation' => true,
  94. 'phpdoc_align' => false, // Waste of time
  95. 'phpdoc_annotation_without_dot' => true,
  96. 'phpdoc_indent' => true,
  97. 'phpdoc_inline_tag' => true,
  98. 'phpdoc_no_access' => true,
  99. 'phpdoc_no_alias_tag' => true,
  100. 'phpdoc_no_empty_return' => true,
  101. 'phpdoc_no_package' => true,
  102. 'phpdoc_no_useless_inheritdoc' => true,
  103. 'phpdoc_order' => true,
  104. 'phpdoc_return_self_reference' => true,
  105. 'phpdoc_scalar' => true,
  106. 'phpdoc_separation' => false,
  107. 'phpdoc_single_line_var_spacing' => true,
  108. 'phpdoc_summary' => false,
  109. 'phpdoc_to_comment' => true,
  110. 'phpdoc_trim' => true,
  111. 'phpdoc_types' => true,
  112. 'phpdoc_var_without_name' => true,
  113. 'pow_to_exponentiation' => false,
  114. 'pre_increment' => false,
  115. 'protected_to_private' => true,
  116. 'psr0' => true,
  117. 'psr4' => true,
  118. 'random_api_migration' => false, // This breaks our unit tests
  119. 'return_type_declaration' => true,
  120. 'self_accessor' => true,
  121. 'semicolon_after_instruction' => false, // Buggy in `samples/index.php`
  122. 'short_scalar_cast' => true,
  123. 'silenced_deprecation_error' => true,
  124. 'simplified_null_return' => false, // While technically correct we prefer to be explicit when returning null
  125. 'single_blank_line_at_eof' => true,
  126. 'single_blank_line_before_namespace' => true,
  127. 'single_class_element_per_statement' => true,
  128. 'single_import_per_statement' => true,
  129. 'single_line_after_imports' => true,
  130. 'single_quote' => true,
  131. 'space_after_semicolon' => true,
  132. 'standardize_not_equals' => true,
  133. 'strict_comparison' => false, // No, too dangerous to change that
  134. 'strict_param' => false, // No, too dangerous to change that
  135. 'switch_case_semicolon_to_colon' => true,
  136. 'switch_case_space' => true,
  137. 'ternary_operator_spaces' => true,
  138. 'ternary_to_null_coalescing' => false, // Cannot use that with PHP 5.6
  139. 'trailing_comma_in_multiline_array' => true,
  140. 'trim_array_spaces' => false,
  141. 'unary_operator_spaces' => true,
  142. 'visibility_required' => true,
  143. 'whitespace_after_comma_in_array' => true,
  144. ));