From 059a96668989150bd8f9d1bb283cf802bf7ce0e5 Mon Sep 17 00:00:00 2001 From: Georg Ringer Date: Tue, 2 Jul 2024 13:58:38 +0200 Subject: [PATCH] followup --- Build/php-cs-fixer/php-cs-fixer.php | 126 ++++++++++++++++++++++------ composer.json | 3 +- 2 files changed, 103 insertions(+), 26 deletions(-) diff --git a/Build/php-cs-fixer/php-cs-fixer.php b/Build/php-cs-fixer/php-cs-fixer.php index b03be97..e0b0abb 100644 --- a/Build/php-cs-fixer/php-cs-fixer.php +++ b/Build/php-cs-fixer/php-cs-fixer.php @@ -1,46 +1,35 @@ setHeader( - 'This file is part of the "csv2xlf" Extension for TYPO3 CMS. +$finder = PhpCsFixer\Finder::create() + ->in(realpath(__DIR__ . '/../../')); -For the full copyright and license information, please read the -LICENSE.txt file that was distributed with this source code.', - true -); -$config->setFinder( - (new PhpCsFixer\Finder()) - ->in(realpath(__DIR__ . '/../../')) - ->ignoreVCSIgnored(true) - ->notPath('/^.Build\//') - ->notPath('/^Build\/php-cs-fixer\/php-cs-fixer.php/') - ->notPath('/^Build\/phpunit\/(UnitTestsBootstrap|FunctionalTestsBootstrap).php/') - ->notPath('/^Configuration\//') - ->notPath('/^Documentation\//') - ->notName('/^ext_(emconf|localconf|tables).php/') -) +$config = new PhpCsFixer\Config(); +$config + ->setParallelConfig(\PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect()) + ->setCacheFile(__DIR__ . '/.php-cs-fixer.cache') + ->registerCustomFixers(new PhpCsFixerCustomFixers\Fixers()) ->setRiskyAllowed(true) ->setRules([ '@DoctrineAnnotation' => true, '@PER-CS' => true, 'array_syntax' => ['syntax' => 'short'], 'blank_line_after_opening_tag' => true, + 'single_space_around_construct' => true, 'control_structure_braces' => true, 'control_structure_continuation_position' => true, 'declare_parentheses' => true, 'no_multiple_statements_per_line' => true, - 'braces_position' => true, - 'statement_indentation' => true, + 'statement_indentation' => ['stick_comment_to_next_continuous_control_statement' => true], 'no_extra_blank_lines' => true, - 'cast_spaces' => ['space' => 'none'], + 'cast_spaces' => true, + 'compact_nullable_type_declaration' => true, 'concat_space' => ['spacing' => 'one'], 'declare_equal_normalize' => ['space' => 'none'], 'dir_constant' => true, - 'new_with_parentheses' => true, 'lowercase_cast' => true, - 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], 'modernize_types_casting' => true, 'native_function_casing' => true, + 'new_with_parentheses' => true, 'no_alias_functions' => true, 'no_blank_lines_after_phpdoc' => true, 'no_empty_phpdoc' => true, @@ -65,7 +54,6 @@ 'phpdoc_no_empty_return' => true, 'phpdoc_no_package' => true, 'phpdoc_scalar' => true, - 'phpdoc_trim' => true, 'phpdoc_types' => true, 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], 'return_type_declaration' => ['space_before' => 'none'], @@ -75,5 +63,93 @@ 'trailing_comma_in_multiline' => ['elements' => ['arrays']], 'whitespace_after_comma_in_array' => ['ensure_single_space' => true], 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], - ]); + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_whitespace_before_comma_in_array' => true, + 'normalize_index_brace' => true, + 'trim_array_spaces' => true, + 'braces_position' => true, + 'constant_case' => true, + 'lowercase_keywords' => true, + 'lowercase_static_reference' => true, + 'magic_constant_casing' => true, + 'magic_method_casing' => true, + 'native_type_declaration_casing' => true, + 'no_unset_cast' => true, + 'short_scalar_cast' => true, + 'class_attributes_separation' => ['elements' => ['method' => 'one']], + 'class_definition' => true, + 'single_class_element_per_statement' => true, + 'visibility_required' => true, + 'multiline_comment_opening_closing' => true, + 'no_empty_comment' => true, + 'single_line_comment_spacing' => true, + 'elseif' => true, + 'empty_loop_body' => ['style' => 'braces'], + 'no_alternative_syntax' => ['fix_non_monolithic_code' => true], + 'no_unneeded_braces' => ['namespaces' => true], + 'switch_case_semicolon_to_colon' => true, + 'switch_case_space' => true, + 'function_declaration' => true, + 'lambda_not_used_import' => true, + 'method_argument_space' => ['on_multiline' => 'ignore'], + 'no_spaces_after_function_name' => true, + 'nullable_type_declaration' => ['syntax' => 'question_mark'], + 'nullable_type_declaration_for_default_null_value' => true, + 'no_unneeded_import_alias' => true, + 'single_import_per_statement' => true, + 'single_line_after_imports' => true, + 'list_syntax' => true, + 'blank_line_after_namespace' => true, + 'blank_lines_before_namespace' => true, + 'clean_namespace' => true, + 'binary_operator_spaces' => true, + 'no_space_around_double_colon' => true, + 'object_operator_without_whitespace' => true, + 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + 'full_opening_tag' => true, + 'linebreak_after_opening_tag' => true, + 'no_closing_tag' => true, + 'align_multiline_comment' => true, + 'no_superfluous_phpdoc_tags' => ['allow_hidden_params' => true, 'remove_inheritdoc' => true], + 'phpdoc_indent' => true, + 'phpdoc_no_useless_inheritdoc' => true, + 'phpdoc_param_order' => true, + 'phpdoc_return_self_reference' => true, + 'phpdoc_single_line_var_spacing' => true, + 'phpdoc_to_comment' => true, + 'phpdoc_trim_consecutive_blank_line_separation' => true, + 'phpdoc_trim' => true, + 'phpdoc_var_annotation_correct_order' => true, + 'phpdoc_var_without_name' => true, + 'no_useless_return' => true, + 'return_assignment' => true, + 'multiline_whitespace_before_semicolons' => true, + 'simple_to_complex_string_variable' => true, + 'array_indentation' => true, + 'blank_line_between_import_groups' => true, + 'method_chaining_indentation' => true, + 'no_spaces_around_offset' => true, + 'no_trailing_whitespace' => true, + 'single_blank_line_at_eof' => true, + 'spaces_inside_parentheses' => true, + 'type_declaration_spaces' => true, + 'types_spaces' => true, + \PhpCsFixerCustomFixers\Fixer\NoDuplicatedArrayKeyFixer::name() => true, + \PhpCsFixerCustomFixers\Fixer\NoDuplicatedImportsFixer::name() => true, + \PhpCsFixerCustomFixers\Fixer\NoPhpStormGeneratedCommentFixer::name() => true, + \PhpCsFixerCustomFixers\Fixer\NoSuperfluousConcatenationFixer::name() => true, + \PhpCsFixerCustomFixers\Fixer\NoTrailingCommaInSinglelineFixer::name() => true, + \PhpCsFixerCustomFixers\Fixer\NoUselessCommentFixer::name() => true, + \PhpCsFixerCustomFixers\Fixer\NoUselessDirnameCallFixer::name() => true, + \PhpCsFixerCustomFixers\Fixer\NoUselessParenthesisFixer::name() => true, + \PhpCsFixerCustomFixers\Fixer\PhpUnitDedicatedAssertFixer::name() => true, + \PhpCsFixerCustomFixers\Fixer\PhpUnitAssertArgumentsOrderFixer::name() => true, + \PhpCsFixerCustomFixers\Fixer\PhpdocSingleLineVarFixer::name() => true, + \PhpCsFixerCustomFixers\Fixer\PhpdocTypesTrimFixer::name() => true, + \PhpCsFixerCustomFixers\Fixer\SingleSpaceAfterStatementFixer::name() => true, + ]) + ->setFinder($finder); + + return $config; diff --git a/composer.json b/composer.json index e7be68b..66bdead 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "typo3/cms-form": "^11.5.30 || ^12.4.5", "phpunit/phpunit": "^9", "typo3/coding-standards": "^0.5.3", - "friendsofphp/php-cs-fixer": "^3.51.0", + "friendsofphp/php-cs-fixer": "^3", + "kubawerlos/php-cs-fixer-custom-fixers": "^3.21", "webmozart/assert": "^1.11.0" }, "autoload": {