joshgaber /
NovaUnit
| 1 | <?php |
||
| 2 | |||
| 3 | use PhpCsFixer\Config; |
||
|
0 ignored issues
–
show
|
|||
| 4 | use PhpCsFixer\Finder; |
||
| 5 | |||
| 6 | $rules = [ |
||
| 7 | 'array_syntax' => ['syntax' => 'short'], |
||
| 8 | 'align_multiline_comment' => ['comment_type' => 'phpdocs_only'], |
||
| 9 | 'binary_operator_spaces' => [ |
||
| 10 | 'default' => 'single_space', |
||
| 11 | ], |
||
| 12 | 'blank_line_after_namespace' => true, |
||
| 13 | 'blank_line_after_opening_tag' => true, |
||
| 14 | 'blank_line_before_statement' => [ |
||
| 15 | 'statements' => ['return'], |
||
| 16 | ], |
||
| 17 | 'braces' => [ |
||
| 18 | 'position_after_anonymous_constructs' => 'same', |
||
| 19 | ], |
||
| 20 | 'cast_spaces' => true, |
||
| 21 | 'class_attributes_separation' => [ |
||
| 22 | 'elements' => ['method' => 'one', 'trait_import' => 'none'], |
||
| 23 | ], |
||
| 24 | 'class_definition' => true, |
||
| 25 | 'concat_space' => [ |
||
| 26 | 'spacing' => 'none', |
||
| 27 | ], |
||
| 28 | 'constant_case' => ['case' => 'lower'], |
||
| 29 | 'declare_equal_normalize' => true, |
||
| 30 | 'elseif' => true, |
||
| 31 | 'encoding' => true, |
||
| 32 | 'full_opening_tag' => true, |
||
| 33 | 'fully_qualified_strict_types' => true, // added by Shift |
||
| 34 | 'function_declaration' => true, |
||
| 35 | 'function_typehint_space' => true, |
||
| 36 | 'general_phpdoc_tag_rename' => true, |
||
| 37 | 'heredoc_to_nowdoc' => true, |
||
| 38 | 'include' => true, |
||
| 39 | 'increment_style' => ['style' => 'post'], |
||
| 40 | 'indentation_type' => true, |
||
| 41 | 'linebreak_after_opening_tag' => true, |
||
| 42 | 'line_ending' => true, |
||
| 43 | 'lowercase_cast' => true, |
||
| 44 | 'lowercase_keywords' => true, |
||
| 45 | 'lowercase_static_reference' => true, // added from Symfony |
||
| 46 | 'magic_method_casing' => true, // added from Symfony |
||
| 47 | 'magic_constant_casing' => true, |
||
| 48 | 'method_argument_space' => true, |
||
| 49 | 'native_function_casing' => true, |
||
| 50 | 'no_alias_functions' => true, |
||
| 51 | 'no_extra_blank_lines' => [ |
||
| 52 | 'tokens' => [ |
||
| 53 | 'extra', |
||
| 54 | 'throw', |
||
| 55 | 'use', |
||
| 56 | ], |
||
| 57 | ], |
||
| 58 | 'no_blank_lines_after_class_opening' => true, |
||
| 59 | 'no_blank_lines_after_phpdoc' => true, |
||
| 60 | 'no_closing_tag' => true, |
||
| 61 | 'no_empty_phpdoc' => true, |
||
| 62 | 'no_empty_statement' => true, |
||
| 63 | 'no_leading_import_slash' => true, |
||
| 64 | 'no_leading_namespace_whitespace' => true, |
||
| 65 | 'no_mixed_echo_print' => [ |
||
| 66 | 'use' => 'echo', |
||
| 67 | ], |
||
| 68 | 'no_multiline_whitespace_around_double_arrow' => true, |
||
| 69 | 'multiline_whitespace_before_semicolons' => [ |
||
| 70 | 'strategy' => 'no_multi_line', |
||
| 71 | ], |
||
| 72 | 'no_short_bool_cast' => true, |
||
| 73 | 'no_singleline_whitespace_before_semicolons' => true, |
||
| 74 | 'no_spaces_after_function_name' => true, |
||
| 75 | 'no_spaces_around_offset' => true, |
||
| 76 | 'no_spaces_inside_parenthesis' => true, |
||
| 77 | 'no_trailing_comma_in_list_call' => true, |
||
| 78 | 'no_trailing_comma_in_singleline_array' => true, |
||
| 79 | 'no_trailing_whitespace' => true, |
||
| 80 | 'no_trailing_whitespace_in_comment' => true, |
||
| 81 | 'no_unneeded_control_parentheses' => true, |
||
| 82 | 'no_unreachable_default_argument_value' => true, |
||
| 83 | 'no_unused_imports' => true, |
||
| 84 | 'no_useless_return' => true, |
||
| 85 | 'no_whitespace_before_comma_in_array' => true, |
||
| 86 | 'no_whitespace_in_blank_line' => true, |
||
| 87 | 'normalize_index_brace' => true, |
||
| 88 | 'not_operator_with_successor_space' => true, |
||
| 89 | 'object_operator_without_whitespace' => true, |
||
| 90 | 'ordered_imports' => ['sort_algorithm' => 'alpha'], |
||
| 91 | 'phpdoc_indent' => true, |
||
| 92 | 'phpdoc_inline_tag_normalizer' => true, |
||
| 93 | 'phpdoc_no_access' => true, |
||
| 94 | 'phpdoc_no_package' => true, |
||
| 95 | 'phpdoc_no_useless_inheritdoc' => true, |
||
| 96 | 'phpdoc_scalar' => true, |
||
| 97 | 'phpdoc_single_line_var_spacing' => true, |
||
| 98 | 'phpdoc_summary' => true, |
||
| 99 | 'phpdoc_tag_type' => [ |
||
| 100 | 'tags' => ['inheritdoc' => 'inline'], |
||
| 101 | ], |
||
| 102 | 'phpdoc_to_comment' => true, |
||
| 103 | 'phpdoc_trim' => true, |
||
| 104 | 'phpdoc_types' => true, |
||
| 105 | 'phpdoc_var_without_name' => true, |
||
| 106 | 'psr_autoloading' => true, |
||
| 107 | 'self_accessor' => true, |
||
| 108 | 'short_scalar_cast' => true, |
||
| 109 | 'simplified_null_return' => true, |
||
| 110 | 'single_blank_line_at_eof' => true, |
||
| 111 | 'single_blank_line_before_namespace' => true, |
||
| 112 | 'single_class_element_per_statement' => true, |
||
| 113 | 'single_import_per_statement' => true, |
||
| 114 | 'single_line_after_imports' => true, |
||
| 115 | 'single_line_comment_style' => [ |
||
| 116 | 'comment_types' => ['hash'], |
||
| 117 | ], |
||
| 118 | 'single_quote' => true, |
||
| 119 | 'space_after_semicolon' => true, |
||
| 120 | 'standardize_not_equals' => true, |
||
| 121 | 'switch_case_semicolon_to_colon' => true, |
||
| 122 | 'switch_case_space' => true, |
||
| 123 | 'ternary_operator_spaces' => true, |
||
| 124 | 'trailing_comma_in_multiline' => [ |
||
| 125 | 'elements' => ['arrays'], |
||
| 126 | ], |
||
| 127 | 'trim_array_spaces' => true, |
||
| 128 | 'unary_operator_spaces' => true, |
||
| 129 | 'visibility_required' => [ |
||
| 130 | 'elements' => ['method', 'property'], |
||
| 131 | ], |
||
| 132 | 'whitespace_after_comma_in_array' => true, |
||
| 133 | ]; |
||
| 134 | $finder = Finder::create() |
||
| 135 | ->notPath('bootstrap') |
||
| 136 | ->notPath('storage') |
||
| 137 | ->notPath('vendor') |
||
| 138 | ->in(getcwd()) |
||
| 139 | ->name('*.php') |
||
| 140 | ->notName('*.blade.php') |
||
| 141 | ->notName('index.php') |
||
| 142 | ->notName('server.php') |
||
| 143 | ->notName('_ide_helper.php') |
||
| 144 | ->ignoreDotFiles(true) |
||
| 145 | ->ignoreVCS(true); |
||
| 146 | |||
| 147 | return (new Config) |
||
| 148 | ->setFinder($finder) |
||
| 149 | ->setRules($rules) |
||
| 150 | ->setRiskyAllowed(true) |
||
| 151 | ->setUsingCache(true); |
||
| 152 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: