‪TYPO3CMS  10.4
php-cs-fixer.php
Go to the documentation of this file.
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  */
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 = (new PhpCsFixer\Finder())
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 (new \PhpCsFixer\Config())
54  ->setRiskyAllowed(true)
55  ->setRules([
56  '@DoctrineAnnotation' => true,
57  '@PSR2' => true,
58  'array_syntax' => ['syntax' => 'short'],
59  'blank_line_after_opening_tag' => true,
60  'braces' => ['allow_single_line_closure' => true],
61  'cast_spaces' => ['space' => 'none'],
62  'compact_nullable_typehint' => true,
63  'concat_space' => ['spacing' => 'one'],
64  'declare_equal_normalize' => ['space' => 'none'],
65  'dir_constant' => true,
66  'function_typehint_space' => true,
67  'lowercase_cast' => true,
68  'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
69  'modernize_types_casting' => true,
70  'native_function_casing' => true,
71  'new_with_braces' => true,
72  'no_alias_functions' => true,
73  'no_blank_lines_after_phpdoc' => true,
74  'no_empty_phpdoc' => true,
75  'no_empty_statement' => true,
76  'no_extra_blank_lines' => true,
77  'no_leading_import_slash' => true,
78  'no_leading_namespace_whitespace' => true,
79  'no_null_property_initialization' => true,
80  'no_short_bool_cast' => true,
81  'no_singleline_whitespace_before_semicolons' => true,
82  'no_superfluous_elseif' => true,
83  'no_trailing_comma_in_singleline_array' => true,
84  'no_unneeded_control_parentheses' => true,
85  'no_unused_imports' => true,
86  'no_useless_else' => true,
87  'no_whitespace_in_blank_line' => true,
88  'ordered_imports' => true,
89  'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']],
90  'php_unit_mock_short_will_return' => true,
91  'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
92  'phpdoc_no_access' => true,
93  'phpdoc_no_empty_return' => true,
94  'phpdoc_no_package' => true,
95  'phpdoc_scalar' => true,
96  'phpdoc_trim' => true,
97  'phpdoc_types' => true,
98  'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
99  'return_type_declaration' => ['space_before' => 'none'],
100  'single_quote' => true,
101  'single_line_comment_style' => ['comment_types' => ['hash']],
102  'single_trait_insert_per_statement' => true,
103  'whitespace_after_comma_in_array' => true,
104  ])
105  ->setFinder(‪$finder);
‪$finder
‪if(PHP_SAPI !=='cli') $finder
Definition: php-cs-fixer.php:36