From e37dc64bdf6e06c0c22e20c035ef5f1cd613207c Mon Sep 17 00:00:00 2001 From: zingimmick Date: Thu, 8 Aug 2024 20:56:07 +0800 Subject: [PATCH] Re-generate ruleset for friendsofphp/php-cs-fixer 3.62 --- config/set/php-cs-fixer-custom.php | 4 ++- config/set/php-cs-fixer/per-cs.php | 4 ++- config/set/php-cs-fixer/per-cs20.php | 4 ++- config/set/php-cs-fixer/per.php | 4 ++- config/set/php-cs-fixer/php-cs-fixer.php | 4 ++- .../phpunit100-migration-risky.php | 1 + .../phpunit91-migration-risky.php | 27 +++++++++++++++++++ config/set/php-cs-fixer/symfony.php | 4 ++- correct/TestClass.php | 2 -- src/PHPCodeSnifferRuleSetGenerator.php | 2 +- src/PhpCsFixerRuleSetGenerator.php | 3 ++- 11 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 config/set/php-cs-fixer/phpunit91-migration-risky.php diff --git a/config/set/php-cs-fixer-custom.php b/config/set/php-cs-fixer-custom.php index e20d9be..f3794ad 100644 --- a/config/set/php-cs-fixer-custom.php +++ b/config/set/php-cs-fixer-custom.php @@ -34,7 +34,9 @@ $ecsConfig->rule(\PhpCsFixer\Fixer\ControlStructure\NoSuperfluousElseifFixer::class); $ecsConfig->rule(\PhpCsFixer\Fixer\ControlStructure\NoUselessElseFixer::class); $ecsConfig->rule(\PhpCsFixer\Fixer\Strict\StrictComparisonFixer::class); - $ecsConfig->rule(\PhpCsFixer\Fixer\Operator\NewWithParenthesesFixer::class); + $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\Operator\NewWithParenthesesFixer::class, [ + 'anonymous_class' => false, + ]); $ecsConfig->rule(\PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer::class); $ecsConfig->rule(\PhpCsFixer\Fixer\FunctionNotation\ImplodeCallFixer::class); $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer::class, [ diff --git a/config/set/php-cs-fixer/per-cs.php b/config/set/php-cs-fixer/per-cs.php index 84392e8..4168a4d 100644 --- a/config/set/php-cs-fixer/per-cs.php +++ b/config/set/php-cs-fixer/per-cs.php @@ -16,7 +16,9 @@ ]); $ecsConfig->rule(\PhpCsFixer\Fixer\Whitespace\IndentationTypeFixer::class); $ecsConfig->rule(\PhpCsFixer\Fixer\ControlStructure\ElseifFixer::class); - $ecsConfig->rule(\PhpCsFixer\Fixer\Operator\NewWithParenthesesFixer::class); + $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\Operator\NewWithParenthesesFixer::class, [ + 'anonymous_class' => false, + ]); $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer::class, [ 'inline_constructor_arguments' => false, 'space_before_parenthesis' => true, diff --git a/config/set/php-cs-fixer/per-cs20.php b/config/set/php-cs-fixer/per-cs20.php index eaaa23a..f3f8482 100644 --- a/config/set/php-cs-fixer/per-cs20.php +++ b/config/set/php-cs-fixer/per-cs20.php @@ -16,7 +16,9 @@ ]); $ecsConfig->rule(\PhpCsFixer\Fixer\Whitespace\IndentationTypeFixer::class); $ecsConfig->rule(\PhpCsFixer\Fixer\ControlStructure\ElseifFixer::class); - $ecsConfig->rule(\PhpCsFixer\Fixer\Operator\NewWithParenthesesFixer::class); + $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\Operator\NewWithParenthesesFixer::class, [ + 'anonymous_class' => false, + ]); $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer::class, [ 'inline_constructor_arguments' => false, 'space_before_parenthesis' => true, diff --git a/config/set/php-cs-fixer/per.php b/config/set/php-cs-fixer/per.php index 84392e8..4168a4d 100644 --- a/config/set/php-cs-fixer/per.php +++ b/config/set/php-cs-fixer/per.php @@ -16,7 +16,9 @@ ]); $ecsConfig->rule(\PhpCsFixer\Fixer\Whitespace\IndentationTypeFixer::class); $ecsConfig->rule(\PhpCsFixer\Fixer\ControlStructure\ElseifFixer::class); - $ecsConfig->rule(\PhpCsFixer\Fixer\Operator\NewWithParenthesesFixer::class); + $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\Operator\NewWithParenthesesFixer::class, [ + 'anonymous_class' => false, + ]); $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer::class, [ 'inline_constructor_arguments' => false, 'space_before_parenthesis' => true, diff --git a/config/set/php-cs-fixer/php-cs-fixer.php b/config/set/php-cs-fixer/php-cs-fixer.php index 9c61051..e81cdfe 100644 --- a/config/set/php-cs-fixer/php-cs-fixer.php +++ b/config/set/php-cs-fixer/php-cs-fixer.php @@ -28,7 +28,9 @@ $ecsConfig->rule(\PhpCsFixer\Fixer\ControlStructure\EmptyLoopBodyFixer::class); $ecsConfig->rule(\PhpCsFixer\Fixer\ControlStructure\NoSuperfluousElseifFixer::class); $ecsConfig->rule(\PhpCsFixer\Fixer\ControlStructure\NoUselessElseFixer::class); - $ecsConfig->rule(\PhpCsFixer\Fixer\Operator\NewWithParenthesesFixer::class); + $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\Operator\NewWithParenthesesFixer::class, [ + 'anonymous_class' => false, + ]); $ecsConfig->rule(\PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer::class); $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer::class, [ 'single_line' => true, diff --git a/config/set/php-cs-fixer/phpunit100-migration-risky.php b/config/set/php-cs-fixer/phpunit100-migration-risky.php index b89c5a1..cf29ef7 100644 --- a/config/set/php-cs-fixer/phpunit100-migration-risky.php +++ b/config/set/php-cs-fixer/phpunit100-migration-risky.php @@ -23,6 +23,7 @@ $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\PhpUnit\PhpUnitDedicateAssertFixer::class, [ 'target' => '5.6', ]); + $ecsConfig->rule(\PhpCsFixer\Fixer\PhpUnit\PhpUnitAssertNewNamesFixer::class); $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\PhpUnit\PhpUnitDedicateAssertInternalTypeFixer::class, [ 'target' => '7.5', ]); diff --git a/config/set/php-cs-fixer/phpunit91-migration-risky.php b/config/set/php-cs-fixer/phpunit91-migration-risky.php new file mode 100644 index 0000000..2742549 --- /dev/null +++ b/config/set/php-cs-fixer/phpunit91-migration-risky.php @@ -0,0 +1,27 @@ +ruleWithConfiguration(\PhpCsFixer\Fixer\PhpUnit\PhpUnitNoExpectationAnnotationFixer::class, [ + 'target' => '4.3', + ]); + $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\PhpUnit\PhpUnitExpectationFixer::class, [ + 'target' => '8.4', + ]); + $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\PhpUnit\PhpUnitNamespacedFixer::class, [ + 'target' => '6.0', + ]); + $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\PhpUnit\PhpUnitMockFixer::class, [ + 'target' => '5.5', + ]); + $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\PhpUnit\PhpUnitDedicateAssertFixer::class, [ + 'target' => '5.6', + ]); + $ecsConfig->rule(\PhpCsFixer\Fixer\PhpUnit\PhpUnitAssertNewNamesFixer::class); + $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\PhpUnit\PhpUnitDedicateAssertInternalTypeFixer::class, [ + 'target' => '7.5', + ]); +}; diff --git a/config/set/php-cs-fixer/symfony.php b/config/set/php-cs-fixer/symfony.php index deb4119..30d2514 100644 --- a/config/set/php-cs-fixer/symfony.php +++ b/config/set/php-cs-fixer/symfony.php @@ -28,7 +28,9 @@ $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\ControlStructure\EmptyLoopBodyFixer::class, [ 'style' => 'braces', ]); - $ecsConfig->rule(\PhpCsFixer\Fixer\Operator\NewWithParenthesesFixer::class); + $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\Operator\NewWithParenthesesFixer::class, [ + 'anonymous_class' => false, + ]); $ecsConfig->rule(\PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer::class); $ecsConfig->ruleWithConfiguration(\PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer::class, [ 'single_line' => true, diff --git a/correct/TestClass.php b/correct/TestClass.php index 287711b..a5042ad 100644 --- a/correct/TestClass.php +++ b/correct/TestClass.php @@ -29,8 +29,6 @@ class TestClass implements TestableContract public $bar; /** - * TestClass constructor. - * * @param \Zing\CodingStandard\Correct\Foo $foo the first param * @param \Zing\CodingStandard\Correct\Bar $bar the second param */ diff --git a/src/PHPCodeSnifferRuleSetGenerator.php b/src/PHPCodeSnifferRuleSetGenerator.php index 2e56f32..c6c8f10 100644 --- a/src/PHPCodeSnifferRuleSetGenerator.php +++ b/src/PHPCodeSnifferRuleSetGenerator.php @@ -46,7 +46,7 @@ public function generate(): void $ruleset->registerSniffs($sniffs, [], []); file_put_contents( - sprintf(__DIR__ . '/../config/set/php_codesniffer/%s', self::MAP[$setDefinition->getRelativePath()]), + \sprintf(__DIR__ . '/../config/set/php_codesniffer/%s', self::MAP[$setDefinition->getRelativePath()]), $this->ruleSetPrinter->print($this->formatRulesToServices($ruleset)) ); } diff --git a/src/PhpCsFixerRuleSetGenerator.php b/src/PhpCsFixerRuleSetGenerator.php index cbbfebe..5e46f54 100644 --- a/src/PhpCsFixerRuleSetGenerator.php +++ b/src/PhpCsFixerRuleSetGenerator.php @@ -47,6 +47,7 @@ final class PhpCsFixerRuleSetGenerator '@PHPUnit60Migration:risky' => 'phpunit60-migration-risky.php', '@PHPUnit75Migration:risky' => 'phpunit75-migration-risky.php', '@PHPUnit84Migration:risky' => 'phpunit84-migration-risky.php', + '@PHPUnit91Migration:risky' => 'phpunit91-migration-risky.php', '@PHPUnit100Migration:risky' => 'phpunit100-migration-risky.php', '@PER' => 'per.php', '@PER:risky' => 'per-risky.php', @@ -79,7 +80,7 @@ public function generate(): void $fixerFactory = new FixerFactory(); $fixerFactory->registerBuiltInFixers(); file_put_contents( - sprintf(__DIR__ . '/../config/set/php-cs-fixer/%s', self::MAP[$setDefinition->getName()]), + \sprintf(__DIR__ . '/../config/set/php-cs-fixer/%s', self::MAP[$setDefinition->getName()]), $this->ruleSetPrinter->print($this->formatRulesToServices($fixerFactory, $setDefinition)) ); }