|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * This source file is proprietary and part of Rebilly. |
| 4 | + * |
| 5 | + * (c) Rebilly SRL |
| 6 | + * Rebilly Ltd. |
| 7 | + * Rebilly Inc. |
| 8 | + * |
| 9 | + * @see https://www.rebilly.com |
| 10 | + */ |
| 11 | + |
| 12 | +$header = <<<'EOF' |
| 13 | +This source file is proprietary and part of Rebilly. |
| 14 | +
|
| 15 | +(c) Rebilly SRL |
| 16 | + Rebilly Ltd. |
| 17 | + Rebilly Inc. |
| 18 | +
|
| 19 | +@see https://www.rebilly.com |
| 20 | +EOF; |
| 21 | + |
| 22 | +$rules = [ |
| 23 | + '@PSR2' => true, |
| 24 | + 'align_multiline_comment' => true, |
| 25 | + 'array_syntax' => ['syntax' => 'short'], |
| 26 | + 'blank_line_before_statement' => true, |
| 27 | + 'binary_operator_spaces' => true, |
| 28 | + 'cast_spaces' => true, |
| 29 | + 'class_attributes_separation' => true, |
| 30 | + 'combine_consecutive_issets' => true, |
| 31 | + 'combine_consecutive_unsets' => true, |
| 32 | + 'combine_nested_dirname' => true, |
| 33 | + 'compact_nullable_typehint' => true, |
| 34 | + 'concat_space' => ['spacing' => 'one'], |
| 35 | + 'declare_equal_normalize' => true, |
| 36 | + // Useful but dangerous fixer. Requires a lot of changes and testing. |
| 37 | + // 'declare_strict_types' => true, |
| 38 | + 'dir_constant' => true, |
| 39 | + 'header_comment' => [ |
| 40 | + 'header' => $header, |
| 41 | + 'commentType' => 'PHPDoc', |
| 42 | + 'separate' => 'bottom', |
| 43 | + 'location' => 'after_open', |
| 44 | + ], |
| 45 | + // Requires php 7.3+. |
| 46 | + // 'heredoc_indentation' => true, |
| 47 | + 'heredoc_to_nowdoc' => true, |
| 48 | + 'general_phpdoc_annotation_remove' => ['annotations' => ['author', 'version']], |
| 49 | + 'is_null' => true, |
| 50 | + 'list_syntax' => ['syntax' => 'short'], |
| 51 | + 'lowercase_cast' => true, |
| 52 | + 'lowercase_static_reference' => true, |
| 53 | + 'magic_constant_casing' => true, |
| 54 | + 'magic_method_casing' => true, |
| 55 | + 'mb_str_functions' => true, |
| 56 | + 'method_argument_space' => ['ensure_fully_multiline' => true], |
| 57 | + 'method_chaining_indentation' => true, |
| 58 | + 'modernize_types_casting' => true, |
| 59 | + 'native_function_casing' => true, |
| 60 | + // We might want this in future. |
| 61 | + // 'native_function_invocation' => true, |
| 62 | + 'new_with_braces' => true, |
| 63 | + 'no_blank_lines_after_class_opening' => true, |
| 64 | + 'no_blank_lines_after_phpdoc' => true, |
| 65 | + 'no_empty_comment' => true, |
| 66 | + 'no_empty_phpdoc' => true, |
| 67 | + 'no_empty_statement' => true, |
| 68 | + 'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']], |
| 69 | + 'no_homoglyph_names' => true, |
| 70 | + 'no_leading_import_slash' => true, |
| 71 | + 'no_leading_namespace_whitespace' => true, |
| 72 | + 'no_mixed_echo_print' => true, |
| 73 | + 'no_multiline_whitespace_around_double_arrow' => true, |
| 74 | + 'no_null_property_initialization' => true, |
| 75 | + 'no_short_bool_cast' => true, |
| 76 | + 'no_singleline_whitespace_before_semicolons' => true, |
| 77 | + 'no_spaces_around_offset' => true, |
| 78 | + 'no_superfluous_elseif' => true, |
| 79 | + 'no_superfluous_phpdoc_tags' => ['allow_mixed' => true], |
| 80 | + 'no_trailing_comma_in_singleline_array' => true, |
| 81 | + 'no_unneeded_control_parentheses' => true, |
| 82 | + 'no_unneeded_curly_braces' => true, |
| 83 | + 'no_unneeded_final_method' => true, |
| 84 | + 'no_unreachable_default_argument_value' => true, |
| 85 | + 'no_unset_on_property' => true, |
| 86 | + 'no_unused_imports' => true, |
| 87 | + 'no_useless_else' => true, |
| 88 | + 'no_useless_return' => true, |
| 89 | + 'no_whitespace_before_comma_in_array' => true, |
| 90 | + 'no_whitespace_in_blank_line' => true, |
| 91 | + 'normalize_index_brace' => true, |
| 92 | + 'ordered_class_elements' => true, |
| 93 | + 'ordered_imports' => true, |
| 94 | + 'php_unit_construct' => true, |
| 95 | + 'php_unit_dedicate_assert' => ['target' => 'newest'], |
| 96 | + 'php_unit_expectation' => true, |
| 97 | + 'php_unit_method_casing' => true, |
| 98 | + 'php_unit_mock' => true, |
| 99 | + 'php_unit_namespaced' => true, |
| 100 | + 'php_unit_no_expectation_annotation' => true, |
| 101 | + 'php_unit_ordered_covers' => true, |
| 102 | + 'php_unit_set_up_tear_down_visibility' => true, |
| 103 | + 'php_unit_strict' => true, |
| 104 | + 'php_unit_test_annotation' => ['style' => 'annotation'], |
| 105 | + 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], |
| 106 | + 'phpdoc_add_missing_param_annotation' => ['only_untyped' => true], |
| 107 | + 'phpdoc_annotation_without_dot' => true, |
| 108 | + 'phpdoc_indent' => true, |
| 109 | + 'phpdoc_no_useless_inheritdoc' => true, |
| 110 | + 'phpdoc_order' => true, |
| 111 | + 'phpdoc_scalar' => true, |
| 112 | + 'phpdoc_separation' => true, |
| 113 | + 'phpdoc_single_line_var_spacing' => true, |
| 114 | + 'phpdoc_summary' => true, |
| 115 | + 'phpdoc_trim' => true, |
| 116 | + 'phpdoc_trim_consecutive_blank_line_separation' => true, |
| 117 | + 'phpdoc_types' => true, |
| 118 | + 'phpdoc_types_order' => true, |
| 119 | + 'pow_to_exponentiation' => true, |
| 120 | + 'protected_to_private' => true, |
| 121 | + // This does not work well with test cases ATM. |
| 122 | + // 'psr4' => true, |
| 123 | + 'random_api_migration' => true, |
| 124 | + 'return_type_declaration' => true, |
| 125 | + 'self_accessor' => true, |
| 126 | + 'semicolon_after_instruction' => true, |
| 127 | + 'short_scalar_cast' => true, |
| 128 | + 'single_line_comment_style' => true, |
| 129 | + 'single_quote' => true, |
| 130 | + 'space_after_semicolon' => true, |
| 131 | + 'standardize_not_equals' => true, |
| 132 | + 'strict_comparison' => true, |
| 133 | + 'strict_param' => true, |
| 134 | + 'ternary_operator_spaces' => true, |
| 135 | + 'ternary_to_null_coalescing' => true, |
| 136 | + 'trailing_comma_in_multiline_array' => true, |
| 137 | + 'trim_array_spaces' => true, |
| 138 | + 'unary_operator_spaces' => true, |
| 139 | + 'visibility_required' => ['property', 'method', 'const'], |
| 140 | + 'void_return' => true, |
| 141 | + 'whitespace_after_comma_in_array' => true, |
| 142 | + 'yoda_style' => ['equal' => false, 'identical' => false], |
| 143 | + 'object_operator_without_whitespace' => true, |
| 144 | +]; |
| 145 | + |
| 146 | +$includeDirs = [ |
| 147 | + __DIR__ . '/src', |
| 148 | + __DIR__ . '/tests', |
| 149 | +]; |
| 150 | + |
| 151 | +$excludeDirs = []; |
| 152 | + |
| 153 | +$finder = PhpCsFixer\Finder::create() |
| 154 | + ->ignoreDotFiles(true) |
| 155 | + ->exclude($excludeDirs) |
| 156 | + ->in($includeDirs); |
| 157 | + |
| 158 | +$config = PhpCsFixer\Config::create() |
| 159 | + ->setRiskyAllowed(true) |
| 160 | + ->setRules($rules) |
| 161 | + ->setFinder($finder); |
| 162 | + |
| 163 | +return $config; |
0 commit comments