|
| 1 | +<?php |
| 2 | + |
| 3 | +$finder = PhpCsFixer\Finder::create() |
| 4 | + ->exclude('node_modules') |
| 5 | + ->exclude('vendor') |
| 6 | + ->in(__DIR__) |
| 7 | + ->name('*.php') |
| 8 | + ->notName('*.blade.php') |
| 9 | + ->ignoreDotFiles(true) |
| 10 | + ->ignoreVCS(true); |
| 11 | + |
| 12 | +return PhpCsFixer\Config::create() |
| 13 | + ->setFinder($finder) |
| 14 | + ->setRules([ |
| 15 | + '@PSR2' => true, |
| 16 | + 'phpdoc_no_empty_return' => false, |
| 17 | + 'phpdoc_var_annotation_correct_order' => true, |
| 18 | + 'array_syntax' => [ |
| 19 | + 'syntax' => 'short', |
| 20 | + ], |
| 21 | + 'no_singleline_whitespace_before_semicolons' => true, |
| 22 | + 'no_extra_blank_lines' => [ |
| 23 | + 'break', 'case', 'continue', 'curly_brace_block', 'default', |
| 24 | + 'extra', 'parenthesis_brace_block', 'return', |
| 25 | + 'square_brace_block', 'switch', 'throw', 'use', 'useTrait', 'use_trait', |
| 26 | + ], |
| 27 | + 'cast_spaces' => [ |
| 28 | + 'space' => 'single', |
| 29 | + ], |
| 30 | + 'concat_space' => [ |
| 31 | + 'spacing' => 'one', |
| 32 | + ], |
| 33 | + 'ordered_imports' => [ |
| 34 | + 'sort_algorithm' => 'length', |
| 35 | + ], |
| 36 | + 'single_quote' => true, |
| 37 | + 'lowercase_cast' => true, |
| 38 | + 'lowercase_static_reference' => true, |
| 39 | + 'no_empty_phpdoc' => true, |
| 40 | + 'no_empty_comment' => true, |
| 41 | + 'array_indentation' => true, |
| 42 | + // TODO: This isn't working, causes fixer to error. |
| 43 | + // 'increment_style' => ['style' => 'post'], |
| 44 | + 'short_scalar_cast' => true, |
| 45 | + 'class_attributes_separation' => [ |
| 46 | + 'elements' => ['const', 'method', 'property'], |
| 47 | + ], |
| 48 | + 'no_mixed_echo_print' => [ |
| 49 | + 'use' => 'echo', |
| 50 | + ], |
| 51 | + 'no_unused_imports' => true, |
| 52 | + 'binary_operator_spaces' => [ |
| 53 | + 'default' => 'single_space', |
| 54 | + ], |
| 55 | + 'no_empty_statement' => true, |
| 56 | + 'unary_operator_spaces' => true, // $number ++ becomes $number++ |
| 57 | + 'hash_to_slash_comment' => true, // # becomes // |
| 58 | + 'standardize_not_equals' => true, // <> becomes != |
| 59 | + 'native_function_casing' => true, |
| 60 | + 'ternary_operator_spaces' => true, |
| 61 | + 'ternary_to_null_coalescing' => true, |
| 62 | + 'declare_equal_normalize' => [ |
| 63 | + 'space' => 'single', |
| 64 | + ], |
| 65 | + 'function_typehint_space' => true, |
| 66 | + 'no_leading_import_slash' => true, |
| 67 | + 'blank_line_before_statement' => [ |
| 68 | + 'statements' => [ |
| 69 | + 'break', 'case', 'continue', |
| 70 | + 'declare', 'default', 'die', |
| 71 | + 'do', 'exit', 'for', 'foreach', |
| 72 | + 'goto', 'if', 'include', |
| 73 | + 'include_once', 'require', 'require_once', |
| 74 | + 'return', 'switch', 'throw', 'try', 'while', 'yield', |
| 75 | + ], |
| 76 | + ], |
| 77 | + 'combine_consecutive_unsets' => true, |
| 78 | + 'method_chaining_indentation' => true, |
| 79 | + 'no_whitespace_in_blank_line' => true, |
| 80 | + 'blank_line_after_opening_tag' => true, |
| 81 | + 'no_trailing_comma_in_list_call' => true, |
| 82 | + 'list_syntax' => ['syntax' => 'short'], |
| 83 | + // public function getTimezoneAttribute( ? Banana $value) becomes public function getTimezoneAttribute(?Banana $value) |
| 84 | + 'compact_nullable_typehint' => true, |
| 85 | + 'explicit_string_variable' => true, |
| 86 | + 'no_leading_namespace_whitespace' => true, |
| 87 | + 'trailing_comma_in_multiline_array' => true, |
| 88 | + 'not_operator_with_successor_space' => true, |
| 89 | + 'object_operator_without_whitespace' => true, |
| 90 | + 'single_blank_line_before_namespace' => true, |
| 91 | + 'no_blank_lines_after_class_opening' => true, |
| 92 | + 'no_blank_lines_after_phpdoc' => true, |
| 93 | + 'no_whitespace_before_comma_in_array' => true, |
| 94 | + 'no_trailing_comma_in_singleline_array' => true, |
| 95 | + 'multiline_whitespace_before_semicolons' => [ |
| 96 | + 'strategy' => 'no_multi_line', |
| 97 | + ], |
| 98 | + 'no_multiline_whitespace_around_double_arrow' => true, |
| 99 | + 'no_useless_return' => true, |
| 100 | + 'phpdoc_add_missing_param_annotation' => true, |
| 101 | + 'phpdoc_order' => true, |
| 102 | + 'phpdoc_scalar' => true, |
| 103 | + 'phpdoc_separation' => true, |
| 104 | + 'phpdoc_single_line_var_spacing' => true, |
| 105 | + 'single_trait_insert_per_statement' => true, |
| 106 | + 'ordered_class_elements' => [ |
| 107 | + 'order' => [ |
| 108 | + 'use_trait', |
| 109 | + 'constant', |
| 110 | + 'property', |
| 111 | + 'construct', |
| 112 | + 'public', |
| 113 | + 'protected', |
| 114 | + 'private', |
| 115 | + ], |
| 116 | + 'sortAlgorithm' => 'none', |
| 117 | + ], |
| 118 | + 'return_type_declaration' => [ |
| 119 | + 'space_before' => 'none', |
| 120 | + ], |
| 121 | + ]) |
| 122 | + ->setLineEnding("\n"); |
0 commit comments