From 6d8ca28bcb6cd2b9c67edc3d77b8d3390fb78a0f Mon Sep 17 00:00:00 2001 From: Simon Schaufelberger Date: Fri, 5 Jan 2024 16:09:27 +0100 Subject: [PATCH] [FEATURE] Add RemoveWorkspacePlaceholderShadowColumnsConfigurationRector Resolves: #1827 Resolves: #1829 Resolves: #3837 Resolves: #3852 --- config/v11/tca-110.php | 11 ++++ ...holderShadowColumnsConfigurationRector.php | 58 +++++++++++++++++++ .../Fixture/fixture.php.inc | 22 +++++++ ...erShadowColumnsConfigurationRectorTest.php | 32 ++++++++++ .../config/configured_rule.php | 11 ++++ 5 files changed, 134 insertions(+) create mode 100644 config/v11/tca-110.php create mode 100644 src/Rector/v11/v0/tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector.php create mode 100644 tests/Rector/v11/v0/tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector/Fixture/fixture.php.inc create mode 100644 tests/Rector/v11/v0/tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector/RemoveWorkspacePlaceholderShadowColumnsConfigurationRectorTest.php create mode 100644 tests/Rector/v11/v0/tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector/config/configured_rule.php diff --git a/config/v11/tca-110.php b/config/v11/tca-110.php new file mode 100644 index 000000000..502789023 --- /dev/null +++ b/config/v11/tca-110.php @@ -0,0 +1,11 @@ +import(__DIR__ . '/../config.php'); + $rectorConfig->rule(RemoveWorkspacePlaceholderShadowColumnsConfigurationRector::class); +}; diff --git a/src/Rector/v11/v0/tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector.php b/src/Rector/v11/v0/tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector.php new file mode 100644 index 000000000..58be2dec9 --- /dev/null +++ b/src/Rector/v11/v0/tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector.php @@ -0,0 +1,58 @@ + [ + 'shadowColumnsForNewPlaceholders' => '', + 'shadowColumnsForMovePlaceholders' => '', + ], +]; +CODE_SAMPLE + , + <<<'CODE_SAMPLE' +return [ + 'ctrl' => [ + ], +]; +CODE_SAMPLE + )]); + } + + protected function refactorCtrl(Array_ $ctrlArray): void + { + $shadowColumnsForNewPlaceholdersArrayItem = $this->extractArrayItemByKey($ctrlArray, 'shadowColumnsForNewPlaceholders'); + if ($shadowColumnsForNewPlaceholdersArrayItem instanceof ArrayItem) { + $this->removeNode($shadowColumnsForNewPlaceholdersArrayItem); + $this->hasAstBeenChanged = true; + } + + $shadowColumnsForMovePlaceholdersArrayItem = $this->extractArrayItemByKey($ctrlArray, 'shadowColumnsForMovePlaceholders'); + if ($shadowColumnsForMovePlaceholdersArrayItem instanceof ArrayItem) { + $this->removeNode($shadowColumnsForMovePlaceholdersArrayItem); + $this->hasAstBeenChanged = true; + } + } +} diff --git a/tests/Rector/v11/v0/tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector/Fixture/fixture.php.inc b/tests/Rector/v11/v0/tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector/Fixture/fixture.php.inc new file mode 100644 index 000000000..94411539b --- /dev/null +++ b/tests/Rector/v11/v0/tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector/Fixture/fixture.php.inc @@ -0,0 +1,22 @@ + [ + 'shadowColumnsForNewPlaceholders' => '', + 'shadowColumnsForMovePlaceholders' => '', + ], + 'columns' => [], +]; +?> +----- + [], + 'columns' => [], +]; +?> diff --git a/tests/Rector/v11/v0/tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector/RemoveWorkspacePlaceholderShadowColumnsConfigurationRectorTest.php b/tests/Rector/v11/v0/tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector/RemoveWorkspacePlaceholderShadowColumnsConfigurationRectorTest.php new file mode 100644 index 000000000..c666f47da --- /dev/null +++ b/tests/Rector/v11/v0/tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector/RemoveWorkspacePlaceholderShadowColumnsConfigurationRectorTest.php @@ -0,0 +1,32 @@ +doTestFile($filePath); + } + + /** + * @return Iterator> + */ + public function provideData(): Iterator + { + return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + public function provideConfigFilePath(): string + { + return __DIR__ . '/config/configured_rule.php'; + } +} diff --git a/tests/Rector/v11/v0/tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector/config/configured_rule.php b/tests/Rector/v11/v0/tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector/config/configured_rule.php new file mode 100644 index 000000000..030889ad4 --- /dev/null +++ b/tests/Rector/v11/v0/tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector/config/configured_rule.php @@ -0,0 +1,11 @@ +import(__DIR__ . '/../../../../../../../config/config_test.php'); + $rectorConfig->rule(RemoveWorkspacePlaceholderShadowColumnsConfigurationRector::class); +};