‪TYPO3CMS  11.5
config.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
30 if (PHP_SAPI !== 'cli') {
31  die('This script supports command line usage only. Please check your command.');
32 }
33 
34 // Return a Code Sniffing configuration using
35 // all sniffers needed for PSR-2
36 // and additionally:
37 // - Remove leading slashes in use clauses.
38 // - PHP single-line arrays should not have trailing comma.
39 // - Single-line whitespace before closing semicolon are prohibited.
40 // - Remove unused use statements in the PHP source code
41 // - Ensure Concatenation to have at least one whitespace around
42 // - Remove trailing whitespace at the end of blank lines.
43 return (new \PhpCsFixer\Config())
44  ->setFinder(
45  (new PhpCsFixer\Finder())
46  ->ignoreVCSIgnored(true)
47  ->in(realpath(__DIR__ . '/../../'))
48  )
49  ->setRiskyAllowed(true)
50  ->setRules([
51  '@DoctrineAnnotation' => true,
52  // @todo: Switch to @PER-CS2.0 once php-cs-fixer's todo list is done: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7247
53  '@PER-CS1.0' => true,
54  'array_indentation' => true,
55  'array_syntax' => ['syntax' => 'short'],
56  'blank_line_after_opening_tag' => true,
57  'braces' => ['allow_single_line_closure' => true],
58  'cast_spaces' => ['space' => 'none'],
59  'compact_nullable_typehint' => true,
60  // @todo: Can be dropped once we enable @PER-CS2.0
61  'concat_space' => ['spacing' => 'one'],
62  'declare_equal_normalize' => ['space' => 'none'],
63  'dir_constant' => true,
64  // @todo: Can be dropped once we enable @PER-CS2.0
65  'function_declaration' => [
66  'closure_fn_spacing' => 'none',
67  ],
68  'function_typehint_space' => true,
69  'lowercase_cast' => true,
70  'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
71  'modernize_types_casting' => true,
72  'native_function_casing' => true,
73  'new_with_braces' => true,
74  'no_alias_functions' => true,
75  'no_blank_lines_after_phpdoc' => true,
76  'no_empty_phpdoc' => true,
77  'no_empty_statement' => true,
78  'no_extra_blank_lines' => true,
79  'no_leading_import_slash' => true,
80  'no_leading_namespace_whitespace' => true,
81  'no_null_property_initialization' => true,
82  'no_short_bool_cast' => true,
83  'no_singleline_whitespace_before_semicolons' => true,
84  'no_superfluous_elseif' => true,
85  'no_trailing_comma_in_singleline' => true,
86  'no_unneeded_control_parentheses' => true,
87  'no_unused_imports' => true,
88  'no_useless_else' => true,
89  'no_useless_nullsafe_operator' => true,
90  'no_whitespace_in_blank_line' => true,
91  'ordered_imports' => true,
92  'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']],
93  'php_unit_mock_short_will_return' => true,
94  'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
95  'phpdoc_no_access' => true,
96  'phpdoc_no_empty_return' => true,
97  'phpdoc_no_package' => true,
98  'phpdoc_scalar' => true,
99  'phpdoc_trim' => true,
100  'phpdoc_types' => true,
101  'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
102  'return_type_declaration' => ['space_before' => 'none'],
103  'single_quote' => true,
104  'single_line_comment_style' => ['comment_types' => ['hash']],
105  // @todo: Can be dropped once we enable @PER-CS2.0
106  'single_line_empty_body' => true,
107  'single_trait_insert_per_statement' => true,
108  'trailing_comma_in_multiline' => ['elements' => ['arrays']],
109  'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
110  'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
111  ]);