|
| 1 | +#!/usr/bin/env php |
| 2 | +<?php |
| 3 | + |
| 4 | +$rules = [ |
| 5 | + 'array_indentation' => true, |
| 6 | + 'array_syntax' => ['syntax' => 'short'], |
| 7 | + 'binary_operator_spaces' => ['default' => 'single_space'], |
| 8 | + 'blank_line_after_namespace' => true, |
| 9 | + 'blank_line_after_opening_tag' => true, |
| 10 | + 'blank_line_before_statement' => [ |
| 11 | + 'statements' => [ |
| 12 | + 'continue', 'declare', 'return', 'throw', 'try', 'do', 'if', |
| 13 | + 'switch' |
| 14 | + ] |
| 15 | + ], |
| 16 | + 'braces' => true, |
| 17 | + 'cast_spaces' => ['space' => 'single'], |
| 18 | + 'class_attributes_separation' => true, |
| 19 | + 'class_definition' => ['singleLine' => true], |
| 20 | + 'concat_space' => ['spacing' => 'none'], |
| 21 | + 'declare_equal_normalize' => ['space' => 'none'], |
| 22 | + 'elseif' => true, |
| 23 | + 'encoding' => true, |
| 24 | + 'full_opening_tag' => true, |
| 25 | + 'function_declaration' => true, |
| 26 | + 'function_typehint_space' => true, |
| 27 | + 'heredoc_to_nowdoc' => true, |
| 28 | + 'include' => true, |
| 29 | + 'indentation_type' => true, |
| 30 | + 'line_ending' => true, |
| 31 | + 'linebreak_after_opening_tag' => true, |
| 32 | + 'lowercase_cast' => true, |
| 33 | + 'lowercase_constants' => true, |
| 34 | + 'lowercase_keywords' => true, |
| 35 | + 'magic_constant_casing' => true, |
| 36 | + 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], |
| 37 | + 'method_chaining_indentation' => true, |
| 38 | + 'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'], |
| 39 | + 'native_function_casing' => true, |
| 40 | + 'no_alias_functions' => ['sets' => ['@internal', '@IMAP']], // Risky |
| 41 | + 'no_blank_lines_after_class_opening' => true, |
| 42 | + 'no_blank_lines_after_phpdoc' => true, |
| 43 | + 'no_closing_tag' => true, |
| 44 | + 'no_empty_comment' => false, |
| 45 | + 'no_empty_phpdoc' => true, |
| 46 | + 'no_empty_statement' => true, |
| 47 | + 'no_extra_blank_lines' => [ |
| 48 | + 'break', 'case', 'continue', 'curly_brace_block', 'default', 'extra', |
| 49 | + 'parenthesis_brace_block', 'square_brace_block', 'throw', |
| 50 | + 'use', 'useTrait', 'use_trait' |
| 51 | + ], |
| 52 | + 'no_leading_import_slash' => true, |
| 53 | + 'no_leading_namespace_whitespace' => true, |
| 54 | + 'no_mixed_echo_print' => ['use' => 'echo'], |
| 55 | + 'no_multiline_whitespace_around_double_arrow' => true, |
| 56 | + 'no_php4_constructor' => true, |
| 57 | + 'no_short_bool_cast' => true, |
| 58 | + 'no_singleline_whitespace_before_semicolons' => true, |
| 59 | + 'no_spaces_after_function_name' => true, |
| 60 | + 'no_spaces_inside_parenthesis' => true, |
| 61 | + 'no_trailing_comma_in_list_call' => true, |
| 62 | + 'no_trailing_comma_in_singleline_array' => true, |
| 63 | + 'no_trailing_whitespace_in_comment' => true, |
| 64 | + 'no_trailing_whitespace' => true, |
| 65 | + 'no_unneeded_control_parentheses' => true, |
| 66 | + 'no_unused_imports' => true, |
| 67 | + 'no_useless_else' => true, |
| 68 | + 'no_useless_return' => true, |
| 69 | + 'no_whitespace_before_comma_in_array' => true, |
| 70 | + 'no_whitespace_in_blank_line' => true, |
| 71 | + 'normalize_index_brace' => true, |
| 72 | + 'not_operator_with_successor_space' => true, |
| 73 | + 'object_operator_without_whitespace' => true, |
| 74 | + 'ordered_imports' => ['sortAlgorithm' => 'length'], |
| 75 | + 'php_unit_strict' => true, |
| 76 | + 'phpdoc_indent' => true, |
| 77 | + 'phpdoc_inline_tag' => true, |
| 78 | + 'phpdoc_no_access' => true, |
| 79 | + 'phpdoc_no_empty_return' => true, |
| 80 | + 'phpdoc_no_package' => true, |
| 81 | + 'phpdoc_no_useless_inheritdoc' => true, |
| 82 | + 'phpdoc_order' => true, |
| 83 | + 'phpdoc_scalar' => [ |
| 84 | + 'types' => [ |
| 85 | + 'boolean', 'double', 'integer', 'real', 'str' |
| 86 | + ] |
| 87 | + ], |
| 88 | + 'phpdoc_single_line_var_spacing' => true, |
| 89 | + 'phpdoc_summary' => true, |
| 90 | + 'phpdoc_to_comment' => true, |
| 91 | + 'phpdoc_trim' => true, |
| 92 | + 'phpdoc_types' => ['groups' => ['simple', 'alias', 'meta']], |
| 93 | + 'phpdoc_var_without_name' => true, |
| 94 | + 'psr4' => true, |
| 95 | + 'self_accessor' => true, |
| 96 | + 'short_scalar_cast' => true, |
| 97 | + 'simplified_null_return' => true, |
| 98 | + 'single_blank_line_at_eof' => true, |
| 99 | + 'single_blank_line_before_namespace' => true, |
| 100 | + 'single_class_element_per_statement' => ['const', 'property'], |
| 101 | + 'single_import_per_statement' => true, |
| 102 | + 'single_line_after_imports' => true, |
| 103 | + 'single_line_comment_style' => true, // defaults comment_types => ['asterisk', 'hash'] |
| 104 | + 'single_quote' => true, |
| 105 | + 'space_after_semicolon' => true, |
| 106 | + 'standardize_increment' => true, |
| 107 | + 'standardize_not_equals' => true, |
| 108 | + 'switch_case_semicolon_to_colon' => true, |
| 109 | + 'switch_case_space' => true, |
| 110 | + 'ternary_operator_spaces' => true, |
| 111 | + 'trailing_comma_in_multiline_array' => true, |
| 112 | + 'trim_array_spaces' => true, |
| 113 | + 'unary_operator_spaces' => true, |
| 114 | + 'visibility_required' => ['property', 'method'], |
| 115 | + 'whitespace_after_comma_in_array' => true, |
| 116 | + // 'align_phpdoc' => true, |
| 117 | + // 'concat_without_spaces' => true, |
| 118 | + // 'hash_to_slash_comment' => true, |
| 119 | + // 'no_unreachable_default_argument_value' => true, // risky |
| 120 | + // 'strict_comparison' => true // risky |
| 121 | +]; |
| 122 | + |
| 123 | +$excludes = [ |
| 124 | + 'bootstrap/cache', |
| 125 | + 'node_modules', |
| 126 | + 'storage', |
| 127 | + 'public', |
| 128 | + 'docs' |
| 129 | +]; |
| 130 | + |
| 131 | +$finder = PhpCsFixer\Finder::create() |
| 132 | + ->exclude($excludes) |
| 133 | + ->in(__DIR__) |
| 134 | + ->notName('*.blade.php') |
| 135 | + ->notName('.phpstorm.meta.php') |
| 136 | + ->notName('_ide_*.php'); |
| 137 | + |
| 138 | +return PhpCsFixer\Config::create() |
| 139 | + ->setRiskyAllowed(true) |
| 140 | + ->setRules($rules) |
| 141 | + ->setFinder($finder); |
0 commit comments