-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Add RemoveWorkspacePlaceholderShadowColumnsConfigurationRector
- Loading branch information
1 parent
94413e0
commit 608f5ff
Showing
5 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Ssch\TYPO3Rector\Rector\v11\v0\tca\RemoveWorkspacePlaceholderShadowColumnsConfigurationRector; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->import(__DIR__ . '/../config.php'); | ||
$rectorConfig->rule(RemoveWorkspacePlaceholderShadowColumnsConfigurationRector::class); | ||
}; |
58 changes: 58 additions & 0 deletions
58
src/Rector/v11/v0/tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ssch\TYPO3Rector\Rector\v11\v0\tca; | ||
|
||
use PhpParser\Node\Expr\Array_; | ||
use PhpParser\Node\Expr\ArrayItem; | ||
use Ssch\TYPO3Rector\Rector\Tca\AbstractTcaRector; | ||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; | ||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; | ||
|
||
/** | ||
* @changelog https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/11.0/Breaking-92791-NewPlaceholderRecordsRemovedInWorkspaces.html | ||
* @changelog https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/11.0/Breaking-92497-WorkspacesMovePlaceholdersRemoved.html | ||
* @see \Ssch\TYPO3Rector\Tests\Rector\v11\v0\tca\RemoveWorkspacePlaceholderShadowColumnsConfigurationRector\RemoveWorkspacePlaceholderShadowColumnsConfigurationRectorTest | ||
*/ | ||
final class RemoveWorkspacePlaceholderShadowColumnsConfigurationRector extends AbstractTcaRector | ||
{ | ||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
public function getRuleDefinition(): RuleDefinition | ||
{ | ||
return new RuleDefinition('removeWorkspacePlaceholderShadowColumnsConfiguration', [new CodeSample( | ||
<<<'CODE_SAMPLE' | ||
return [ | ||
'ctrl' => [ | ||
'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; | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...v0/tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector/Fixture/fixture.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Ssch\TYPO3Rector\Tests\Rector\v11\v0\tca\RemoveWorkspacePlaceholderShadowColumnsConfigurationRector\Fixture; | ||
|
||
return [ | ||
'ctrl' => [ | ||
'shadowColumnsForNewPlaceholders' => '', | ||
'shadowColumnsForMovePlaceholders' => '', | ||
], | ||
'columns' => [], | ||
]; | ||
?> | ||
----- | ||
<?php | ||
|
||
namespace Ssch\TYPO3Rector\Tests\Rector\v11\v0\tca\RemoveWorkspacePlaceholderShadowColumnsConfigurationRector\Fixture; | ||
|
||
return [ | ||
'ctrl' => [], | ||
'columns' => [], | ||
]; | ||
?> |
32 changes: 32 additions & 0 deletions
32
...mnsConfigurationRector/RemoveWorkspacePlaceholderShadowColumnsConfigurationRectorTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ssch\TYPO3Rector\Tests\Rector\v11\v0\tca\RemoveWorkspacePlaceholderShadowColumnsConfigurationRector; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class RemoveWorkspacePlaceholderShadowColumnsConfigurationRectorTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
/** | ||
* @return Iterator<array<string>> | ||
*/ | ||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/configured_rule.php'; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...tca/RemoveWorkspacePlaceholderShadowColumnsConfigurationRector/config/configured_rule.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Ssch\TYPO3Rector\Rector\v11\v0\tca\RemoveWorkspacePlaceholderShadowColumnsConfigurationRector; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->import(__DIR__ . '/../../../../../../../config/config_test.php'); | ||
$rectorConfig->rule(RemoveWorkspacePlaceholderShadowColumnsConfigurationRector::class); | ||
}; |