Issues (8)

.php-cs-fixer.php (1 issue)

Labels
Severity
1
<?php
2
3
use PhpCsFixer\Config;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Config. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are 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.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/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:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
4
use PhpCsFixer\Finder;
5
6
$rules = [
7
    'array_syntax' => ['syntax' => 'short'],
8
    'binary_operator_spaces' => [
9
        'default' => 'single_space',
10
        'operators' => ['=>' => null]
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' => true,
18
    'cast_spaces' => true,
19
    'class_attributes_separation' => [
20
        'elements' => ['method' => 'one']
21
    ],
22
    'class_definition' => true,
23
    'concat_space' => [
24
        'spacing' => 'one'
25
    ],
26
    'declare_equal_normalize' => true,
27
    'elseif' => true,
28
    'encoding' => true,
29
    'full_opening_tag' => true,
30
    'fully_qualified_strict_types' => true,
31
    'function_declaration' => true,
32
    'function_typehint_space' => true,
33
    'heredoc_to_nowdoc' => true,
34
    'include' => true,
35
    'increment_style' => ['style' => 'post'],
36
    'indentation_type' => true,
37
    'linebreak_after_opening_tag' => true,
38
    'line_ending' => true,
39
    'lowercase_cast' => true,
40
    'constant_case' => true,
41
    'lowercase_keywords' => true,
42
    'lowercase_static_reference' => true,
43
    'magic_method_casing' => true,
44
    'magic_constant_casing' => true,
45
    'method_argument_space' => true,
46
    'native_function_casing' => true,
47
    'no_alias_functions' => true,
48
    'no_extra_blank_lines' => [
49
        'tokens' => [
50
            'extra',
51
            'throw',
52
            'use',
53
            'use_trait',
54
        ]
55
    ],
56
    'no_blank_lines_after_class_opening' => true,
57
    'no_blank_lines_after_phpdoc' => true,
58
    'no_closing_tag' => true,
59
    'no_empty_phpdoc' => true,
60
    'no_empty_statement' => true,
61
    'no_leading_import_slash' => true,
62
    'no_leading_namespace_whitespace' => true,
63
    'no_mixed_echo_print' => [
64
        'use' => 'echo'
65
    ],
66
    'no_multiline_whitespace_around_double_arrow' => true,
67
    'multiline_whitespace_before_semicolons' => [
68
        'strategy' => 'no_multi_line'
69
    ],
70
    'no_short_bool_cast' => true,
71
    'no_singleline_whitespace_before_semicolons' => true,
72
    'no_spaces_after_function_name' => true,
73
    'no_spaces_around_offset' => true,
74
    'no_spaces_inside_parenthesis' => true,
75
    'no_trailing_comma_in_list_call' => true,
76
    'no_trailing_comma_in_singleline_array' => true,
77
    'no_trailing_whitespace' => true,
78
    'no_trailing_whitespace_in_comment' => true,
79
    'no_unneeded_control_parentheses' => true,
80
    'no_unreachable_default_argument_value' => true,
81
    'no_useless_return' => true,
82
    'no_whitespace_before_comma_in_array' => true,
83
    'no_whitespace_in_blank_line' => true,
84
    'normalize_index_brace' => true,
85
    'not_operator_with_successor_space' => false,
86
    'object_operator_without_whitespace' => true,
87
    'ordered_imports' => ['sort_algorithm' => 'alpha'],
88
    'phpdoc_indent' => true,
89
    'general_phpdoc_tag_rename' => true,
90
    'phpdoc_inline_tag_normalizer' => true,
91
    'phpdoc_tag_type' => true,
92
    'phpdoc_no_access' => true,
93
    'phpdoc_no_package' => true,
94
    'phpdoc_no_useless_inheritdoc' => true,
95
    'phpdoc_scalar' => true,
96
    'phpdoc_single_line_var_spacing' => true,
97
    'phpdoc_summary' => true,
98
    'phpdoc_to_comment' => true,
99
    'phpdoc_trim' => true,
100
    'phpdoc_types' => true,
101
    'phpdoc_var_without_name' => true,
102
    'psr_autoloading' => true,
103
    'self_accessor' => true,
104
    'short_scalar_cast' => true,
105
    'simplified_null_return' => false,
106
    'single_blank_line_at_eof' => true,
107
    'single_blank_line_before_namespace' => true,
108
    'single_class_element_per_statement' => true,
109
    'single_import_per_statement' => true,
110
    'single_line_after_imports' => true,
111
    'single_line_comment_style' => [
112
        'comment_types' => ['hash']
113
    ],
114
    'single_quote' => true,
115
    'space_after_semicolon' => true,
116
    'standardize_not_equals' => true,
117
    'switch_case_semicolon_to_colon' => true,
118
    'switch_case_space' => true,
119
    'ternary_operator_spaces' => true,
120
    'trailing_comma_in_multiline' => true,
121
    'trim_array_spaces' => true,
122
    'unary_operator_spaces' => true,
123
    'visibility_required' => [
124
        'elements' => ['method', 'property']
125
    ],
126
    'whitespace_after_comma_in_array' => true,
127
    'no_unused_imports' => true,
128
];
129
130
131
$finder = Finder::create()
132
    ->in([
133
        __DIR__ . '/src',
134
    ])
135
    ->name('*.php')
136
    ->notName('*.blade.php')
137
    ->ignoreDotFiles(true)
138
    ->ignoreVCS(true);
139
140
$config = new Config();
141
return $config->setFinder($finder)
142
    ->setRules($rules)
143
    ->setRiskyAllowed(true)
144
    ->setUsingCache(true);
145