Passed
Push — main ( 8c9c8d...7d21ad )
by Seth
08:02 queued 04:58
created

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

Labels
Severity
1
<?php
2
3
use PhpCsFixer\Finder;
4
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...
5
6
$finder = Finder::create()
7
    ->in(__DIR__ . '/src/');
8
9
$config = new Config();
10
11
return $config->setFinder($finder)
12
    ->setRules([
13
        '@PSR12' => true,
14
        'array_syntax' => ['syntax' => 'short'],
15
        'combine_consecutive_unsets' => true,
16
        'multiline_whitespace_before_semicolons' => true,
17
        'single_quote' => true,
18
        'binary_operator_spaces' => ['default' => 'single_space'],
19
        'blank_line_before_statement' => ['statements' => ['return']],
20
        'braces' => [
21
            'allow_single_line_closure' => true,
22
            'position_after_anonymous_constructs' => 'same',
23
            'position_after_control_structures' => 'same',
24
            'position_after_functions_and_oop_constructs' => 'next',
25
        ],
26
        'combine_consecutive_issets' => true,
27
        'class_attributes_separation' => ['elements' => ['method' => 'one']],
28
        'concat_space' => ['spacing' => 'one'],
29
        'include' => true,
30
        'no_extra_blank_lines' => [
31
            'tokens' => [
32
                'curly_brace_block',
33
                'extra',
34
                'parenthesis_brace_block',
35
                'square_brace_block',
36
                'throw',
37
                'use',
38
            ],
39
        ],
40
        'no_multiline_whitespace_around_double_arrow' => true,
41
        'no_spaces_around_offset' => true,
42
        'no_unused_imports' => true,
43
        'no_whitespace_before_comma_in_array' => true,
44
        'object_operator_without_whitespace' => true,
45
        'php_unit_fqcn_annotation' => true,
46
        'phpdoc_no_package' => true,
47
        'phpdoc_scalar' => true,
48
        'phpdoc_single_line_var_spacing' => true,
49
        'protected_to_private' => true,
50
        'return_assignment' => true,
51
        'no_useless_return' => true,
52
        'simplified_null_return' => true,
53
        'single_line_after_imports' => true,
54
        'single_line_comment_style' => ['comment_types' => ['hash']],
55
        'single_class_element_per_statement' => true,
56
        'trailing_comma_in_multiline' => ['elements' => ['arrays']],
57
        'trim_array_spaces' => true,
58
        'unary_operator_spaces' => true,
59
        'whitespace_after_comma_in_array' => true,
60
        'no_null_property_initialization' => true,
61
62
        'function_typehint_space' => true,
63
        'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
64
        'no_empty_statement' => true,
65
        'no_leading_namespace_whitespace' => true,
66
        'return_type_declaration' => ['space_before' => 'none'],
67
68
        'method_chaining_indentation' => true,
69
        'align_multiline_comment' => ['comment_type' => 'all_multiline'],
70
        'no_superfluous_phpdoc_tags' => [
71
            'allow_mixed' => false,
72
            'remove_inheritdoc' => false,
73
            'allow_unused_params' => false,
74
        ],
75
        'phpdoc_trim_consecutive_blank_line_separation' => true,
76
        'phpdoc_trim' => true,
77
        'no_empty_phpdoc' => true,
78
        'clean_namespace' => true,
79
        'array_indentation' => true,
80
        'elseif' => true,
81
        'phpdoc_order' => true,
82
        'global_namespace_import' => [
83
            'import_classes' => true,
84
            'import_constants' => false,
85
            'import_functions' => false,
86
        ],
87
        'fully_qualified_strict_types' => true,
88
        'no_leading_import_slash' => true,
89
    ])
90
    ->setLineEnding("\n");
91