From 0123b4277c46b893e0b9955537269836c66fdcdd Mon Sep 17 00:00:00 2001 From: Tommy Quissens Date: Tue, 22 Sep 2020 15:59:51 +0200 Subject: [PATCH] [Downgrade PHP 7.3] Trailing commas in function calls --- config/set/downgrade-php73.php | 3 +- ...DowngradeTrailingCommasInFunctionCalls.php | 63 +++++++++++++++++ .../DowngradeFlexibleHeredocSyntax.php | 70 ------------------- ...gradeTrailingCommasInFunctionCallsTest.php | 40 +++++++++++ .../Fixture/fixture.php.inc | 27 +++++++ .../DowngradeFlexibleHeredocSyntaxTest.php | 31 -------- .../Fixture/fixture.php.inc | 35 ---------- 7 files changed, 131 insertions(+), 138 deletions(-) create mode 100644 rules/downgrade-php73/src/Rector/FuncCall/DowngradeTrailingCommasInFunctionCalls.php delete mode 100644 rules/downgrade-php73/src/Rector/String_/DowngradeFlexibleHeredocSyntax.php create mode 100644 rules/downgrade-php73/tests/Rector/FuncCall/DowngradeTrailingCommasInFunctionCalls/DowngradeTrailingCommasInFunctionCallsTest.php create mode 100644 rules/downgrade-php73/tests/Rector/FuncCall/DowngradeTrailingCommasInFunctionCalls/Fixture/fixture.php.inc delete mode 100644 rules/downgrade-php73/tests/Rector/String_/DowngradeFlexibleHeredocSyntax/DowngradeFlexibleHeredocSyntaxTest.php delete mode 100644 rules/downgrade-php73/tests/Rector/String_/DowngradeFlexibleHeredocSyntax/Fixture/fixture.php.inc diff --git a/config/set/downgrade-php73.php b/config/set/downgrade-php73.php index d64935ca0da..2a4afdbd62b 100644 --- a/config/set/downgrade-php73.php +++ b/config/set/downgrade-php73.php @@ -3,10 +3,9 @@ declare(strict_types=1); use Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCalls; -use Rector\DowngradePhp73\Rector\String_\DowngradeFlexibleHeredocSyntax; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); - $services->set(DowngradeFlexibleHeredocSyntax::class); + $services->set(DowngradeTrailingCommasInFunctionCalls::class); }; diff --git a/rules/downgrade-php73/src/Rector/FuncCall/DowngradeTrailingCommasInFunctionCalls.php b/rules/downgrade-php73/src/Rector/FuncCall/DowngradeTrailingCommasInFunctionCalls.php new file mode 100644 index 00000000000..4b484cfac5c --- /dev/null +++ b/rules/downgrade-php73/src/Rector/FuncCall/DowngradeTrailingCommasInFunctionCalls.php @@ -0,0 +1,63 @@ +setAttribute(AttributeKey::ORIGINAL_NODE, null); + return $node; + } +} diff --git a/rules/downgrade-php73/src/Rector/String_/DowngradeFlexibleHeredocSyntax.php b/rules/downgrade-php73/src/Rector/String_/DowngradeFlexibleHeredocSyntax.php deleted file mode 100644 index fadd5a45ff8..00000000000 --- a/rules/downgrade-php73/src/Rector/String_/DowngradeFlexibleHeredocSyntax.php +++ /dev/null @@ -1,70 +0,0 @@ -getAttribute(AttributeKey::KIND), [String_::KIND_HEREDOC, String_::KIND_NOWDOC], true)) { - return null; - } - - $node->setAttribute('docIndentation', ''); - $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); - - return $node; - } -} diff --git a/rules/downgrade-php73/tests/Rector/FuncCall/DowngradeTrailingCommasInFunctionCalls/DowngradeTrailingCommasInFunctionCallsTest.php b/rules/downgrade-php73/tests/Rector/FuncCall/DowngradeTrailingCommasInFunctionCalls/DowngradeTrailingCommasInFunctionCallsTest.php new file mode 100644 index 00000000000..eeec4cf7ec9 --- /dev/null +++ b/rules/downgrade-php73/tests/Rector/FuncCall/DowngradeTrailingCommasInFunctionCalls/DowngradeTrailingCommasInFunctionCallsTest.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 DowngradeTrailingCommasInFunctionCalls::class; + } + + protected function getPhpVersion(): string + { + return '7.2'; +// TODO: create constant +// return PhpVersionFeature::; + } +} diff --git a/rules/downgrade-php73/tests/Rector/FuncCall/DowngradeTrailingCommasInFunctionCalls/Fixture/fixture.php.inc b/rules/downgrade-php73/tests/Rector/FuncCall/DowngradeTrailingCommasInFunctionCalls/Fixture/fixture.php.inc new file mode 100644 index 00000000000..808956bac86 --- /dev/null +++ b/rules/downgrade-php73/tests/Rector/FuncCall/DowngradeTrailingCommasInFunctionCalls/Fixture/fixture.php.inc @@ -0,0 +1,27 @@ + +----- + diff --git a/rules/downgrade-php73/tests/Rector/String_/DowngradeFlexibleHeredocSyntax/DowngradeFlexibleHeredocSyntaxTest.php b/rules/downgrade-php73/tests/Rector/String_/DowngradeFlexibleHeredocSyntax/DowngradeFlexibleHeredocSyntaxTest.php deleted file mode 100644 index e72c2d718f2..00000000000 --- a/rules/downgrade-php73/tests/Rector/String_/DowngradeFlexibleHeredocSyntax/DowngradeFlexibleHeredocSyntaxTest.php +++ /dev/null @@ -1,31 +0,0 @@ -doTestFileInfo($fileInfo); - } - - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return DowngradeFlexibleHeredocSyntax::class; - } -} diff --git a/rules/downgrade-php73/tests/Rector/String_/DowngradeFlexibleHeredocSyntax/Fixture/fixture.php.inc b/rules/downgrade-php73/tests/Rector/String_/DowngradeFlexibleHeredocSyntax/Fixture/fixture.php.inc deleted file mode 100644 index 5c6151045cb..00000000000 --- a/rules/downgrade-php73/tests/Rector/String_/DowngradeFlexibleHeredocSyntax/Fixture/fixture.php.inc +++ /dev/null @@ -1,35 +0,0 @@ - ------ -