Skip to content

Commit

Permalink
[FEATURE] Add RemoveWorkspacePlaceholderShadowColumnsConfigurationRector
Browse files Browse the repository at this point in the history
Resolves: #1827
Resolves: #1829
Resolves: #3837
Resolves: #3852
  • Loading branch information
simonschaufi committed Jan 5, 2024
1 parent 8a9453d commit 6d8ca28
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 0 deletions.
11 changes: 11 additions & 0 deletions config/v11/tca-110.php
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);
};
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;
}
}
}
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' => [],
];
?>
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';
}
}
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);
};

0 comments on commit 6d8ca28

Please sign in to comment.