[TASK] Update php-cs-fixer configuration to exclude _generated directory
[Packages/TYPO3.CMS.git] / Build / .php_cs
1 <?php
2 /*
3 * This file is part of the TYPO3 CMS project.
4 *
5 * It is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License, either version 2
7 * of the License, or any later version.
8 *
9 * For the full copyright and license information, please read the
10 * LICENSE.txt file that was distributed with this source code.
11 *
12 * The TYPO3 project - inspiring people to share!
13 */
14 /**
15 * This file represents the configuration for Code Sniffing PSR-2-related
16 * automatic checks of coding guidelines
17 * Install @fabpot's great php-cs-fixer tool via
18 *
19 * $ composer global require friendsofphp/php-cs-fixer
20 *
21 * And then simply run
22 *
23 * $ php-cs-fixer fix --config ../Build/.php_cs
24 *
25 * inside the TYPO3 directory. Warning: This may take up to 10 minutes.
26 *
27 * For more information read:
28 * https://www.php-fig.org/psr/psr-2/
29 * https://cs.sensiolabs.org
30 */
31 if (PHP_SAPI !== 'cli') {
32 die('This script supports command line usage only. Please check your command.');
33 }
34 // Define in which folders to search and which folders to exclude
35 // Exclude some directories that are excluded by Git anyways to speed up the sniffing
36 $finder = PhpCsFixer\Finder::create()
37 ->exclude('vendor')
38 ->exclude('typo3conf')
39 ->exclude('typo3temp')
40 ->exclude('typo3/sysext/core/Tests/Acceptance/Support/_generated')
41 ->notName('install.php')
42 ->notName('index.php')
43 ->in(__DIR__ . '/../');
44 // Return a Code Sniffing configuration using
45 // all sniffers needed for PSR-2
46 // and additionally:
47 // - Remove leading slashes in use clauses.
48 // - PHP single-line arrays should not have trailing comma.
49 // - Single-line whitespace before closing semicolon are prohibited.
50 // - Remove unused use statements in the PHP source code
51 // - Ensure Concatenation to have at least one whitespace around
52 // - Remove trailing whitespace at the end of blank lines.
53 return PhpCsFixer\Config::create()
54 ->setRiskyAllowed(true)
55 ->setRules([
56 '@PSR2' => true,
57 '@DoctrineAnnotation' => true,
58 'no_leading_import_slash' => true,
59 'no_trailing_comma_in_singleline_array' => true,
60 'no_singleline_whitespace_before_semicolons' => true,
61 'no_unused_imports' => true,
62 'concat_space' => ['spacing' => 'one'],
63 'no_whitespace_in_blank_line' => true,
64 'ordered_imports' => true,
65 'single_quote' => true,
66 'no_empty_statement' => true,
67 'no_extra_consecutive_blank_lines' => true,
68 'phpdoc_no_package' => true,
69 'phpdoc_scalar' => true,
70 'no_blank_lines_after_phpdoc' => true,
71 'array_syntax' => ['syntax' => 'short'],
72 'whitespace_after_comma_in_array' => true,
73 'function_typehint_space' => true,
74 'hash_to_slash_comment' => true,
75 'no_alias_functions' => true,
76 'lowercase_cast' => true,
77 'no_leading_namespace_whitespace' => true,
78 'native_function_casing' => true,
79 'no_short_bool_cast' => true,
80 'no_unneeded_control_parentheses' => true,
81 'phpdoc_no_empty_return' => true,
82 'phpdoc_trim' => true,
83 'no_superfluous_elseif' => true,
84 'no_useless_else' => true,
85 'phpdoc_types' => true,
86 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
87 'return_type_declaration' => ['space_before' => 'none'],
88 'cast_spaces' => ['space' => 'none'],
89 'declare_equal_normalize' => ['space' => 'single'],
90 'dir_constant' => true,
91 'phpdoc_no_access' => true
92 ])
93 ->setFinder($finder);