diff --git a/composer.json b/composer.json index d0c747e29..d4b3aec1c 100644 --- a/composer.json +++ b/composer.json @@ -34,6 +34,7 @@ "symfony/polyfill-php80": "^1.26", "symfony/polyfill-php81": "^1.26", "symfony/string": "^5.0 || ^6.0", + "symfony/yaml": "^5.0 || ^6.0", "symplify/smart-file-system": "^9.3 || ^10.0 || ^11.0", "webmozart/assert": "^1.0" }, diff --git a/config/config.php b/config/config.php index 5356bce8e..98ca69dd0 100644 --- a/config/config.php +++ b/config/config.php @@ -35,19 +35,19 @@ $services->load('Ssch\\TYPO3Rector\\', __DIR__ . '/../src') ->exclude([ __DIR__ . '/../src/Rector', - __DIR__ . '/../src/Set', - __DIR__ . '/../src/ValueObject', __DIR__ . '/../src/AttributeDecorator/ExtbaseValidateAttributeDecorator.php', - __DIR__ . '/../src/FileProcessor/TypoScript/Conditions', - __DIR__ . '/../src/FileProcessor/TypoScript/Rector', - __DIR__ . '/../src/FileProcessor/TypoScript/PostRector', - __DIR__ . '/../src/FileProcessor/Yaml/Form/Rector', + __DIR__ . '/../src/Console/Application/Typo3RectorKernel.php', __DIR__ . '/../src/FileProcessor/Composer/Rector', __DIR__ . '/../src/FileProcessor/FlexForms/Rector', - __DIR__ . '/../src/FileProcessor/Resources/Icons/Rector', - __DIR__ . '/../src/FileProcessor/Resources/Files/Rector', __DIR__ . '/../src/FileProcessor/Fluid/Rector', - __DIR__ . '/../src/Console/Application/Typo3RectorKernel.php', + __DIR__ . '/../src/FileProcessor/Resources/Files/Rector', + __DIR__ . '/../src/FileProcessor/Resources/Icons/Rector', + __DIR__ . '/../src/FileProcessor/TypoScript/Conditions', + __DIR__ . '/../src/FileProcessor/TypoScript/PostRector', + __DIR__ . '/../src/FileProcessor/TypoScript/Rector', + __DIR__ . '/../src/FileProcessor/Yaml/Form/Rector', + __DIR__ . '/../src/Set', + __DIR__ . '/../src/ValueObject', ]); $services->set(Traverser::class); diff --git a/src/Contract/FileProcessor/Yaml/Form/FormYamlRectorInterface.php b/src/Contract/FileProcessor/Yaml/YamlRectorInterface.php similarity index 63% rename from src/Contract/FileProcessor/Yaml/Form/FormYamlRectorInterface.php rename to src/Contract/FileProcessor/Yaml/YamlRectorInterface.php index 45db61e67..2f402ff09 100644 --- a/src/Contract/FileProcessor/Yaml/Form/FormYamlRectorInterface.php +++ b/src/Contract/FileProcessor/Yaml/YamlRectorInterface.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Ssch\TYPO3Rector\Contract\FileProcessor\Yaml\Form; +namespace Ssch\TYPO3Rector\Contract\FileProcessor\Yaml; use Rector\Core\Contract\Rector\RectorInterface; -interface FormYamlRectorInterface extends RectorInterface +interface YamlRectorInterface extends RectorInterface { /** * @param mixed[] $yaml diff --git a/src/FileProcessor/Yaml/Form/Rector/v10/v0/EmailFinisherRector.php b/src/FileProcessor/Yaml/Form/Rector/v10/v0/EmailFinisherRector.php index f49954cf5..d688f1752 100644 --- a/src/FileProcessor/Yaml/Form/Rector/v10/v0/EmailFinisherRector.php +++ b/src/FileProcessor/Yaml/Form/Rector/v10/v0/EmailFinisherRector.php @@ -7,7 +7,7 @@ use Rector\ChangesReporting\ValueObject\RectorWithLineChange; use Rector\Core\Provider\CurrentFileProvider; use Rector\Core\ValueObject\Application\File; -use Ssch\TYPO3Rector\Contract\FileProcessor\Yaml\Form\FormYamlRectorInterface; +use Ssch\TYPO3Rector\Contract\FileProcessor\Yaml\YamlRectorInterface; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -15,7 +15,7 @@ * @changelog https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/10.0/Feature-80420-AllowMultipleRecipientsInEmailFinisher.html * @see \Ssch\TYPO3Rector\Tests\FileProcessor\Yaml\Form\Rector\v10\v0\EmailFinisherRector\EmailFinisherRectorTest */ -final class EmailFinisherRector implements FormYamlRectorInterface +final class EmailFinisherRector implements YamlRectorInterface { /** * @var string diff --git a/src/FileProcessor/Yaml/Form/Rector/v10/v0/TranslationFileRector.php b/src/FileProcessor/Yaml/Form/Rector/v10/v0/TranslationFileRector.php index 2c14c7e9f..9b88c75fb 100644 --- a/src/FileProcessor/Yaml/Form/Rector/v10/v0/TranslationFileRector.php +++ b/src/FileProcessor/Yaml/Form/Rector/v10/v0/TranslationFileRector.php @@ -4,7 +4,7 @@ namespace Ssch\TYPO3Rector\FileProcessor\Yaml\Form\Rector\v10\v0; -use Ssch\TYPO3Rector\Contract\FileProcessor\Yaml\Form\FormYamlRectorInterface; +use Ssch\TYPO3Rector\Contract\FileProcessor\Yaml\YamlRectorInterface; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -12,7 +12,7 @@ * @changelog https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/10.0/Breaking-87009-UseMultipleTranslationFilesByDefaultInEXTform.html * @see \Ssch\TYPO3Rector\Tests\FileProcessor\Yaml\Form\Rector\v10\v0\TranslationFileRector\TranslationFileRectorTest */ -final class TranslationFileRector implements FormYamlRectorInterface +final class TranslationFileRector implements YamlRectorInterface { /** * @var string diff --git a/src/FileProcessor/Yaml/Form/FormYamlFileProcessor.php b/src/FileProcessor/Yaml/YamlFileProcessor.php similarity index 84% rename from src/FileProcessor/Yaml/Form/FormYamlFileProcessor.php rename to src/FileProcessor/Yaml/YamlFileProcessor.php index 7c5b85bb8..2b4efe254 100644 --- a/src/FileProcessor/Yaml/Form/FormYamlFileProcessor.php +++ b/src/FileProcessor/Yaml/YamlFileProcessor.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Ssch\TYPO3Rector\FileProcessor\Yaml\Form; +namespace Ssch\TYPO3Rector\FileProcessor\Yaml; use Rector\ChangesReporting\ValueObjectFactory\FileDiffFactory; use Rector\Core\Contract\Processor\FileProcessorInterface; @@ -12,12 +12,12 @@ use Rector\Core\ValueObject\Error\SystemError; use Rector\Core\ValueObject\Reporting\FileDiff; use Rector\Parallel\ValueObject\Bridge; -use Ssch\TYPO3Rector\Contract\FileProcessor\Yaml\Form\FormYamlRectorInterface; +use Ssch\TYPO3Rector\Contract\FileProcessor\Yaml\YamlRectorInterface; use Ssch\TYPO3Rector\Helper\SymfonyYamlParser; use Ssch\TYPO3Rector\ValueObject\Indent; use Symplify\SmartFileSystem\SmartFileInfo; -final class FormYamlFileProcessor implements FileProcessorInterface +final class YamlFileProcessor implements FileProcessorInterface { /** * @var string[] @@ -35,10 +35,10 @@ final class FormYamlFileProcessor implements FileProcessorInterface private FileDiffFactory $fileDiffFactory; /** - * @var FormYamlRectorInterface[] + * @var YamlRectorInterface[] * @readonly */ - private array $transformer = []; + private array $yamlRectors = []; /** * @readonly @@ -46,17 +46,17 @@ final class FormYamlFileProcessor implements FileProcessorInterface private SymfonyYamlParser $symfonyYamlParser; /** - * @param FormYamlRectorInterface[] $transformer + * @param YamlRectorInterface[] $yamlRectors */ public function __construct( CurrentFileProvider $currentFileProvider, FileDiffFactory $fileDiffFactory, SymfonyYamlParser $symfonyYamlParser, - array $transformer + array $yamlRectors ) { $this->currentFileProvider = $currentFileProvider; $this->fileDiffFactory = $fileDiffFactory; - $this->transformer = $transformer; + $this->yamlRectors = $yamlRectors; $this->symfonyYamlParser = $symfonyYamlParser; } @@ -83,8 +83,8 @@ public function process(File $file, Configuration $configuration): array $newYaml = $yaml; - foreach ($this->transformer as $transformer) { - $newYaml = $transformer->refactor($newYaml); + foreach ($this->yamlRectors as $yamlRector) { + $newYaml = $yamlRector->refactor($newYaml); } // Nothing has changed. Early return here. @@ -104,7 +104,7 @@ public function process(File $file, Configuration $configuration): array public function supports(File $file, Configuration $configuration): bool { // Prevent unnecessary processing - if ($this->transformer === []) { + if ($this->yamlRectors === []) { return false; } diff --git a/utils/generator/templates/src/Rector/__Major__/__Minor__/yaml/__Name__.php b/utils/generator/templates/src/Rector/__Major__/__Minor__/yaml/__Name__.php index bb03902ab..c71903d36 100644 --- a/utils/generator/templates/src/Rector/__Major__/__Minor__/yaml/__Name__.php +++ b/utils/generator/templates/src/Rector/__Major__/__Minor__/yaml/__Name__.php @@ -4,7 +4,7 @@ namespace Ssch\TYPO3Rector\Rector\__Major__\__Minor__\__Type__; -use Ssch\TYPO3Rector\Contract\FileProcessor\Yaml\Form\FormYamlRectorInterface; +use Ssch\TYPO3Rector\Contract\FileProcessor\Yaml\YamlRectorInterface; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -12,7 +12,7 @@ * @changelog __Changelog_Url__ * @see \Ssch\TYPO3Rector\Tests\Rector\__Major__\__Minor__\__Type__\__Test_Directory__\__Name__Test */ -final class __Name__ implements FormYamlRectorInterface +final class __Name__ implements YamlRectorInterface { /** * @param mixed[] $yaml