|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/* |
| 6 | + * This file is copied from 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 | + |
| 18 | +/** |
| 19 | + * This file represents the configuration for Code Sniffing PER-related |
| 20 | + * automatic checks of coding guidelines. |
| 21 | + * |
| 22 | + * Run it using runTests.sh, see 'runTests.sh -h' for more options. |
| 23 | + * |
| 24 | + * Fix entire extension: |
| 25 | + * > Build/Scripts/additionalTests.sh -p 8.3 -s composerInstallPackage -q "typo3/cms-core:[dev-main,13...]" |
| 26 | + * > Build/Scripts/runTests.sh -s cgl |
| 27 | + * |
| 28 | + * Fix your current patch: |
| 29 | + * > Build/Scripts/runTests.sh -s cglGit |
| 30 | + */ |
| 31 | +if (PHP_SAPI !== 'cli') { |
| 32 | + die('This script supports command line usage only. Please check your command.'); |
| 33 | +} |
| 34 | + |
| 35 | +// Return a Code Sniffing configuration using |
| 36 | +// all sniffers needed for PER |
| 37 | +// and additionally: |
| 38 | +// - Remove leading slashes in use clauses. |
| 39 | +// - PHP single-line arrays should not have trailing comma. |
| 40 | +// - Single-line whitespace before closing semicolon are prohibited. |
| 41 | +// - Remove unused use statements in the PHP source code |
| 42 | +// - Ensure Concatenation to have at least one whitespace around |
| 43 | +// - Remove trailing whitespace at the end of blank lines. |
| 44 | +return (new \PhpCsFixer\Config()) |
| 45 | + ->setParallelConfig(\PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect()) |
| 46 | + ->setFinder( |
| 47 | + PhpCsFixer\Finder::create() |
| 48 | + ->ignoreVCSIgnored(true) |
| 49 | + ->in(realpath(__DIR__ . '/../../')) |
| 50 | + ->exclude('bin') |
| 51 | + ->exclude('public') |
| 52 | + ->exclude('typo3temp') |
| 53 | + ->exclude('vendor') |
| 54 | + ) |
| 55 | + ->setRiskyAllowed(true) |
| 56 | + ->setRules([ |
| 57 | + '@DoctrineAnnotation' => true, |
| 58 | + // @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 |
| 59 | + '@PER-CS1.0' => true, |
| 60 | + 'array_indentation' => true, |
| 61 | + 'array_syntax' => ['syntax' => 'short'], |
| 62 | + 'cast_spaces' => ['space' => 'none'], |
| 63 | + // @todo: Can be dropped once we enable @PER-CS2.0 |
| 64 | + 'concat_space' => ['spacing' => 'one'], |
| 65 | + 'declare_equal_normalize' => ['space' => 'none'], |
| 66 | + 'declare_parentheses' => true, |
| 67 | + 'dir_constant' => true, |
| 68 | + // @todo: Can be dropped once we enable @PER-CS2.0 |
| 69 | + 'function_declaration' => [ |
| 70 | + 'closure_fn_spacing' => 'none', |
| 71 | + ], |
| 72 | + 'function_to_constant' => ['functions' => ['get_called_class', 'get_class', 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']], |
| 73 | + 'type_declaration_spaces' => true, |
| 74 | + 'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false], |
| 75 | + 'list_syntax' => ['syntax' => 'short'], |
| 76 | + // @todo: Can be dropped once we enable @PER-CS2.0 |
| 77 | + 'method_argument_space' => true, |
| 78 | + 'modernize_strpos' => true, |
| 79 | + 'modernize_types_casting' => true, |
| 80 | + 'native_function_casing' => true, |
| 81 | + 'no_alias_functions' => true, |
| 82 | + 'no_blank_lines_after_phpdoc' => true, |
| 83 | + 'no_empty_phpdoc' => true, |
| 84 | + 'no_empty_statement' => true, |
| 85 | + 'no_extra_blank_lines' => true, |
| 86 | + 'no_leading_namespace_whitespace' => true, |
| 87 | + 'no_null_property_initialization' => true, |
| 88 | + 'no_short_bool_cast' => true, |
| 89 | + 'no_singleline_whitespace_before_semicolons' => true, |
| 90 | + 'no_superfluous_elseif' => true, |
| 91 | + 'no_trailing_comma_in_singleline' => true, |
| 92 | + 'no_unneeded_control_parentheses' => true, |
| 93 | + 'no_unused_imports' => true, |
| 94 | + 'no_useless_else' => true, |
| 95 | + 'no_useless_nullsafe_operator' => true, |
| 96 | + 'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'], |
| 97 | + 'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']], |
| 98 | + 'php_unit_mock_short_will_return' => true, |
| 99 | + 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], |
| 100 | + 'phpdoc_no_access' => true, |
| 101 | + 'phpdoc_no_empty_return' => true, |
| 102 | + 'phpdoc_no_package' => true, |
| 103 | + 'phpdoc_scalar' => true, |
| 104 | + 'phpdoc_trim' => true, |
| 105 | + 'phpdoc_types' => true, |
| 106 | + 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], |
| 107 | + 'return_type_declaration' => ['space_before' => 'none'], |
| 108 | + 'single_quote' => true, |
| 109 | + 'single_space_around_construct' => true, |
| 110 | + 'single_line_comment_style' => ['comment_types' => ['hash']], |
| 111 | + // @todo: Can be dropped once we enable @PER-CS2.0 |
| 112 | + 'single_line_empty_body' => true, |
| 113 | + 'trailing_comma_in_multiline' => ['elements' => ['arrays']], |
| 114 | + 'whitespace_after_comma_in_array' => ['ensure_single_space' => true], |
| 115 | + 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], |
| 116 | + ]); |
0 commit comments