|
| 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 | + * http://www.php-fig.org/psr/psr-2/ |
| 29 | + * http://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 | + ->in('.'); |
| 38 | +// Return a Code Sniffing configuration using |
| 39 | +// all sniffers needed for PSR-2 |
| 40 | +// and additionally: |
| 41 | +// - Remove leading slashes in use clauses. |
| 42 | +// - PHP single-line arrays should not have trailing comma. |
| 43 | +// - Single-line whitespace before closing semicolon are prohibited. |
| 44 | +// - Remove unused use statements in the PHP source code |
| 45 | +// - Ensure Concatenation to have at least one whitespace around |
| 46 | +// - Remove trailing whitespace at the end of blank lines. |
| 47 | +return PhpCsFixer\Config::create() |
| 48 | + ->setRiskyAllowed(true) |
| 49 | + ->setRules([ |
| 50 | + '@PSR2' => true, |
| 51 | + 'no_leading_import_slash' => true, |
| 52 | + 'no_trailing_comma_in_singleline_array' => true, |
| 53 | + 'no_singleline_whitespace_before_semicolons' => true, |
| 54 | + 'no_unused_imports' => true, |
| 55 | + 'concat_space' => ['spacing' => 'one'], |
| 56 | + 'no_whitespace_in_blank_line' => true, |
| 57 | + 'ordered_imports' => true, |
| 58 | + 'single_quote' => true, |
| 59 | + 'no_empty_statement' => true, |
| 60 | + 'no_extra_consecutive_blank_lines' => true, |
| 61 | + 'phpdoc_no_package' => true, |
| 62 | + 'phpdoc_scalar' => true, |
| 63 | + 'no_blank_lines_after_phpdoc' => true, |
| 64 | + 'array_syntax' => ['syntax' => 'short'], |
| 65 | + 'whitespace_after_comma_in_array' => true, |
| 66 | + 'function_typehint_space' => true, |
| 67 | + 'hash_to_slash_comment' => true, |
| 68 | + 'no_alias_functions' => true, |
| 69 | + 'lowercase_cast' => true, |
| 70 | + 'no_leading_namespace_whitespace' => true, |
| 71 | + 'native_function_casing' => true, |
| 72 | + 'self_accessor' => true, |
| 73 | + 'no_short_bool_cast' => true, |
| 74 | + 'no_unneeded_control_parentheses' => true, |
| 75 | + 'phpdoc_no_empty_return' => true, |
| 76 | + 'phpdoc_trim' => true, |
| 77 | + 'no_superfluous_elseif' => true, |
| 78 | + 'no_useless_else' => true, |
| 79 | + ]) |
| 80 | + ->setFinder($finder); |
0 commit comments