|
| 1 | +<?php |
| 2 | + |
| 3 | +use PhpCsFixer\Config; |
| 4 | +use PhpCsFixer\Finder; |
| 5 | + |
| 6 | +$finder = Finder::create() |
| 7 | + ->exclude('node_modules') |
| 8 | + ->exclude('vendor') |
| 9 | + ->in(__DIR__); |
| 10 | + |
| 11 | +$config = new Config(); |
| 12 | + |
| 13 | +return $config |
| 14 | + ->setRules( |
| 15 | + [ |
| 16 | + // Rulesets |
| 17 | + '@PSR12' => true, |
| 18 | + '@PHP83Migration' => true, |
| 19 | + '@PHP84Migration' => true, |
| 20 | + |
| 21 | + // Individual rules |
| 22 | + 'no_multiline_whitespace_around_double_arrow' => true, |
| 23 | + 'no_trailing_comma_in_singleline' => true, |
| 24 | + 'trim_array_spaces' => true, |
| 25 | + 'whitespace_after_comma_in_array' => ['ensure_single_space' => true], |
| 26 | + 'attribute_empty_parentheses' => true, |
| 27 | + 'ordered_attributes' => true, |
| 28 | + 'non_printable_character' => ['use_escape_sequences_in_strings' => true], |
| 29 | + 'class_reference_name_casing' => true, |
| 30 | + 'integer_literal_case' => true, |
| 31 | + 'magic_constant_casing' => true, |
| 32 | + 'magic_method_casing' => true, |
| 33 | + 'native_function_casing' => true, |
| 34 | + 'native_type_declaration_casing' => true, |
| 35 | + 'cast_spaces' => true, |
| 36 | + 'modernize_types_casting' => true, |
| 37 | + 'no_short_bool_cast' => true, |
| 38 | + 'class_attributes_separation' => [ |
| 39 | + 'elements' => [ |
| 40 | + 'const' => 'only_if_meta', |
| 41 | + 'method' => 'one', |
| 42 | + 'property' => 'only_if_meta', |
| 43 | + 'trait_import' => 'none', |
| 44 | + ], |
| 45 | + ], |
| 46 | + 'ordered_interfaces' => true, |
| 47 | + 'ordered_types' => [ |
| 48 | + 'null_adjustment' => 'always_last', |
| 49 | + 'sort_algorithm' => 'none', |
| 50 | + ], |
| 51 | + 'self_static_accessor' => true, |
| 52 | + 'multiline_comment_opening_closing' => true, |
| 53 | + 'single_line_comment_spacing' => true, |
| 54 | + 'empty_loop_condition' => true, |
| 55 | + 'include' => true, |
| 56 | + 'no_alternative_syntax' => ['fix_non_monolithic_code' => false], |
| 57 | + 'no_break_comment' => ['comment_text' => 'No break'], |
| 58 | + 'no_superfluous_elseif' => true, |
| 59 | + 'no_unneeded_braces' => ['namespaces' => true], |
| 60 | + 'no_unneeded_control_parentheses' => true, |
| 61 | + 'no_useless_else' => true, |
| 62 | + 'simplified_if_return' => true, |
| 63 | + 'switch_continue_to_break' => true, |
| 64 | + 'yoda_style' => ['always_move_variable' => true], |
| 65 | + 'combine_nested_dirname' => true, |
| 66 | + 'fopen_flag_order' => true, |
| 67 | + 'implode_call' => true, |
| 68 | + 'lambda_not_used_import' => true, |
| 69 | + 'no_unreachable_default_argument_value' => true, |
| 70 | + 'no_useless_sprintf' => true, |
| 71 | + 'nullable_type_declaration_for_default_null_value' => true, |
| 72 | + 'void_return' => true, |
| 73 | + 'fully_qualified_strict_types' => ['import_symbols' => true], |
| 74 | + 'global_namespace_import' => [ |
| 75 | + 'import_classes' => true, |
| 76 | + 'import_constants' => true, |
| 77 | + 'import_functions' => true, |
| 78 | + ], |
| 79 | + 'no_unneeded_import_alias' => true, |
| 80 | + 'no_unused_imports' => true, |
| 81 | + 'ordered_imports' => [ |
| 82 | + 'imports_order' => ['class', 'function', 'const'], |
| 83 | + 'sort_algorithm' => 'alpha', |
| 84 | + ], |
| 85 | + 'single_import_per_statement' => ['group_to_single_imports' => true], |
| 86 | + 'combine_consecutive_unsets' => true, |
| 87 | + 'declare_parentheses' => true, |
| 88 | + 'dir_constant' => true, |
| 89 | + 'explicit_indirect_variable' => true, |
| 90 | + 'function_to_constant' => true, |
| 91 | + 'get_class_to_class_keyword' => true, |
| 92 | + 'is_null' => true, |
| 93 | + 'nullable_type_declaration' => true, |
| 94 | + 'no_leading_namespace_whitespace' => true, |
| 95 | + 'concat_space' => ['spacing' => 'one'], |
| 96 | + 'logical_operators' => true, |
| 97 | + 'no_useless_nullsafe_operator' => true, |
| 98 | + 'object_operator_without_whitespace' => true, |
| 99 | + 'operator_linebreak' => ['position' => 'end', 'only_booleans' => true], |
| 100 | + 'standardize_not_equals' => true, |
| 101 | + 'ternary_to_elvis_operator' => true, |
| 102 | + 'php_unit_attributes' => true, |
| 103 | + 'php_unit_construct' => true, |
| 104 | + 'php_unit_data_provider_static' => true, |
| 105 | + 'php_unit_dedicate_assert' => ['target' => '5.6'], |
| 106 | + 'php_unit_dedicate_assert_internal_type' => ['target' => '7.5'], |
| 107 | + 'php_unit_expectation' => ['target' => '8.4'], |
| 108 | + 'php_unit_mock_short_will_return' => true, |
| 109 | + 'php_unit_set_up_tear_down_visibility' => true, |
| 110 | + 'php_unit_test_annotation' => true, |
| 111 | + 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], |
| 112 | + 'align_multiline_comment' => true, |
| 113 | + 'no_blank_lines_after_phpdoc' => true, |
| 114 | + 'no_empty_phpdoc' => true, |
| 115 | + 'phpdoc_add_missing_param_annotation' => ['only_untyped' => false], |
| 116 | + 'phpdoc_indent' => true, |
| 117 | + 'phpdoc_inline_tag_normalizer' => true, |
| 118 | + 'phpdoc_no_access' => true, |
| 119 | + 'phpdoc_no_useless_inheritdoc' => true, |
| 120 | + 'phpdoc_param_order' => true, |
| 121 | + 'phpdoc_scalar' => true, |
| 122 | + 'phpdoc_separation' => [ |
| 123 | + 'groups' => [ |
| 124 | + ['deprecated'], |
| 125 | + ['see'], |
| 126 | + ['link'], |
| 127 | + ['author'], |
| 128 | + ['category', 'package', 'subpackage'], |
| 129 | + ['property', 'property-read', 'property-write'], |
| 130 | + ['param'], |
| 131 | + ['phpstan-param', 'psalm-param'], |
| 132 | + ['return'], |
| 133 | + ['phpstan-return', 'psalm-return'], |
| 134 | + ['throws'], |
| 135 | + ], |
| 136 | + ], |
| 137 | + 'phpdoc_single_line_var_spacing' => true, |
| 138 | + 'phpdoc_tag_type' => ['tags' => ['inheritDoc' => 'inline']], |
| 139 | + 'phpdoc_to_comment' => true, |
| 140 | + 'phpdoc_trim_consecutive_blank_line_separation' => true, |
| 141 | + 'phpdoc_trim' => true, |
| 142 | + 'phpdoc_types' => true, |
| 143 | + 'phpdoc_types_order' => [ |
| 144 | + 'null_adjustment' => 'always_last', |
| 145 | + 'sort_algorithm' => 'none', |
| 146 | + ], |
| 147 | + 'phpdoc_var_annotation_correct_order' => true, |
| 148 | + 'phpdoc_var_without_name' => true, |
| 149 | + 'no_useless_return' => true, |
| 150 | + 'return_assignment' => true, |
| 151 | + 'simplified_null_return' => true, |
| 152 | + 'multiline_whitespace_before_semicolons' => true, |
| 153 | + 'no_empty_statement' => true, |
| 154 | + 'no_singleline_whitespace_before_semicolons' => true, |
| 155 | + 'semicolon_after_instruction' => true, |
| 156 | + 'multiline_string_to_heredoc' => true, |
| 157 | + 'single_quote' => true, |
| 158 | + 'array_indentation' => true, |
| 159 | + 'method_chaining_indentation' => true, |
| 160 | + 'no_spaces_around_offset' => true, |
| 161 | + 'type_declaration_spaces' => true, |
| 162 | + 'types_spaces' => ['space_multiple_catch' => 'single'], |
| 163 | + ] |
| 164 | + ) |
| 165 | + ->setLineEnding("\n") |
| 166 | + ->setRiskyAllowed(true) |
| 167 | + ->setFinder($finder); |
0 commit comments