KyleMassacre /
laravel-menus
| 1 | <?php |
||
| 2 | |||
| 3 | use PhpCsFixer\Config; |
||
|
0 ignored issues
–
show
|
|||
| 4 | use PhpCsFixer\Finder; |
||
| 5 | |||
| 6 | $finder = (new Finder()) |
||
| 7 | ->in(__DIR__) |
||
| 8 | ->exclude([ |
||
| 9 | 'vendor', |
||
| 10 | ]); |
||
| 11 | |||
| 12 | return (new Config()) |
||
| 13 | ->setRules([ |
||
| 14 | '@PSR2' => true, |
||
| 15 | // Concatenation should be used with at least one whitespace around. |
||
| 16 | 'concat_space' => ['spacing' => 'one'], |
||
| 17 | // Unused use statements must be removed. |
||
| 18 | 'ordered_imports' => true, |
||
| 19 | // Removes extra empty lines. |
||
| 20 | 'no_extra_blank_lines' => true, |
||
| 21 | // An empty line feed should precede a return statement. |
||
| 22 | 'blank_line_before_statement' => true, |
||
| 23 | // Unused use statements must be removed. |
||
| 24 | 'no_unused_imports' => true, |
||
| 25 | // Remove trailing whitespace at the end of blank lines. |
||
| 26 | 'no_whitespace_in_blank_line' => true, |
||
| 27 | // There MUST be one blank line after the namespace declaration. |
||
| 28 | 'blank_line_after_namespace' => true, |
||
| 29 | // There should be exactly one blank line before a namespace declaration. |
||
| 30 | 'single_blank_line_before_namespace' => true, |
||
| 31 | // Each namespace use MUST go on its own line and there MUST be one blank line after the use statements block. |
||
| 32 | 'single_line_after_imports' => true, |
||
| 33 | // Ensure there is no code on the same line as the PHP open tag and it is followed by a blankline. |
||
| 34 | 'blank_line_after_opening_tag' => true, |
||
| 35 | // Remove duplicated semicolons. |
||
| 36 | 'no_empty_statement' => true, |
||
| 37 | // PHP multi-line arrays should have a trailing comma. |
||
| 38 | 'trailing_comma_in_multiline' => true, |
||
| 39 | // There should be no empty lines after class opening brace. |
||
| 40 | 'no_blank_lines_after_class_opening' => true, |
||
| 41 | // There should not be blank lines between docblock and the documented element. |
||
| 42 | 'no_blank_lines_after_phpdoc' => true, |
||
| 43 | // Phpdocs should start and end with content, excluding the very first and last line of the docblocks. |
||
| 44 | 'phpdoc_trim' => true, |
||
| 45 | 'normalize_index_brace' => true, |
||
| 46 | 'whitespace_after_comma_in_array' => true, |
||
| 47 | ]) |
||
| 48 | ->setFinder($finder); |
||
| 49 |
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: