‪TYPO3CMS  ‪main
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 PER
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  'cast_spaces' => ['space' => 'none'],
57  // @todo: Can be dropped once we enable @PER-CS2.0
58  'concat_space' => ['spacing' => 'one'],
59  'declare_equal_normalize' => ['space' => 'none'],
60  'declare_parentheses' => true,
61  'dir_constant' => true,
62  // @todo: Can be dropped once we enable @PER-CS2.0
63  'function_declaration' => [
64  'closure_fn_spacing' => 'none',
65  ],
66  'function_to_constant' => ['functions' => ['get_called_class', 'get_class', 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']],
67  'type_declaration_spaces' => true,
68  'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false],
69  'list_syntax' => ['syntax' => 'short'],
70  // @todo: Can be dropped once we enable @PER-CS2.0
71  'method_argument_space' => true,
72  'modernize_strpos' => true,
73  'modernize_types_casting' => true,
74  'native_function_casing' => true,
75  'no_alias_functions' => true,
76  'no_blank_lines_after_phpdoc' => true,
77  'no_empty_phpdoc' => true,
78  'no_empty_statement' => true,
79  'no_extra_blank_lines' => 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  'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
91  'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']],
92  'php_unit_mock_short_will_return' => true,
93  'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
94  'phpdoc_no_access' => true,
95  'phpdoc_no_empty_return' => true,
96  'phpdoc_no_package' => true,
97  'phpdoc_scalar' => true,
98  'phpdoc_trim' => true,
99  'phpdoc_types' => true,
100  'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
101  'return_type_declaration' => ['space_before' => 'none'],
102  'single_quote' => true,
103  'single_space_around_construct' => 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  'trailing_comma_in_multiline' => ['elements' => ['arrays']],
108  'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
109  'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
110  ]);