diff --git a/config/set/downgrade-php73.php b/config/set/downgrade-php73.php index 0738b4e6a7f1..9d645da8c358 100644 --- a/config/set/downgrade-php73.php +++ b/config/set/downgrade-php73.php @@ -4,6 +4,7 @@ use Rector\Downgrade\Rector\LNumber\ChangePhpVersionInPlatformCheckRector; use Rector\DowngradePhp73\Rector\List_\DowngradeListReferenceAssignmentRector; +use Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCallsRector; use Rector\DowngradePhp73\Rector\String_\DowngradeFlexibleHeredocSyntaxRector; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; @@ -15,4 +16,5 @@ ->call('configure', [[ ChangePhpVersionInPlatformCheckRector::TARGET_PHP_VERSION => 70300, ]]); + $services->set(DowngradeTrailingCommasInFunctionCallsRector::class); }; diff --git a/rules/downgrade-php73/src/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector.php b/rules/downgrade-php73/src/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector.php new file mode 100644 index 000000000000..85ea41e40b83 --- /dev/null +++ b/rules/downgrade-php73/src/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector.php @@ -0,0 +1,72 @@ +args){ + if(! $node->getAttribute(AttributeKey::PARENT_NODE) instanceof Node\Scalar\Encapsed){ + $node->setAttribute(AttributeKey::ORIGINAL_NODE,null); + } + } + return $node; + } +} diff --git a/rules/downgrade-php73/tests/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector/DowngradeTrailingCommasInFunctionCallsRectorTest.php b/rules/downgrade-php73/tests/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector/DowngradeTrailingCommasInFunctionCallsRectorTest.php new file mode 100644 index 000000000000..1685dd3abc88 --- /dev/null +++ b/rules/downgrade-php73/tests/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector/DowngradeTrailingCommasInFunctionCallsRectorTest.php @@ -0,0 +1,40 @@ += 7.3 + * @dataProvider provideData() + */ + public function test(SmartFileInfo $fileInfo): void + { + $this->doTestFileInfo($fileInfo); + } + + public function provideData(): Iterator + { + return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + protected function getRectorClass(): string + { + return DowngradeTrailingCommasInFunctionCallsRector::class; + } + + protected function getPhpVersion(): string + { + return '7.2'; +// TODO: create constant +// return PhpVersionFeature::; + } +} diff --git a/rules/downgrade-php73/tests/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector/Fixture/fixture.php.inc b/rules/downgrade-php73/tests/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector/Fixture/fixture.php.inc new file mode 100644 index 000000000000..8f13bb6bd77c --- /dev/null +++ b/rules/downgrade-php73/tests/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector/Fixture/fixture.php.inc @@ -0,0 +1,33 @@ +setData('posts','units',); + self::run('posts','units',); + $this->setOnClick("[Zip ID: {$modelid}] {$e->getMessage($modelId,)}"); + } +} + +?> +----- +setData('posts', 'units'); + self::run('posts', 'units'); + $this->setOnClick("[Zip ID: {$modelid}] {$e->getMessage($modelId)}"); + } +} + +?>