diff --git a/config/set/contentrepository-90.php b/config/set/contentrepository-90.php
index 1b80c8b..9990f63 100644
--- a/config/set/contentrepository-90.php
+++ b/config/set/contentrepository-90.php
@@ -100,10 +100,14 @@
]);
$rectorConfig->ruleWithConfiguration(FusionReplacePrototypeNameRector::class, [
- new FusionPrototypeNameReplacement('Neos.Fusion:Array' , 'Neos.Fusion:Join'),
- new FusionPrototypeNameReplacement('Neos.Fusion:RawArray' , 'Neos.Fusion:DataStructure'),
- new FusionPrototypeNameReplacement('Neos.Fusion:Collection' , 'Neos.Fusion:Loop'),
- new FusionPrototypeNameReplacement('Neos.Fusion:RawCollection', 'Neos.Fusion:Map'),
+ new FusionPrototypeNameReplacement('Neos.Fusion:Array', 'Neos.Fusion:Join'),
+ new FusionPrototypeNameReplacement('Neos.Fusion:RawArray', 'Neos.Fusion:DataStructure'),
+ new FusionPrototypeNameReplacement('Neos.Fusion:Collection', 'Neos.Fusion:Loop',
+ 'Migration of Neos.Fusion:Collection to Neos.Fusion:Loop needs manual action. The key `children` has to be renamed to `items` which cannot be done automatically'
+ ),
+ new FusionPrototypeNameReplacement('Neos.Fusion:RawCollection', 'Neos.Fusion:Map',
+ 'Migration of Neos.Fusion:RawCollection to Neos.Fusion:Map needs manual action. The key `children` has to be renamed to `items` which cannot be done automatically'
+ ),
]);
diff --git a/src/Generic/Rules/FusionReplacePrototypeNameRector.php b/src/Generic/Rules/FusionReplacePrototypeNameRector.php
index 89de0fc..1505ae9 100644
--- a/src/Generic/Rules/FusionReplacePrototypeNameRector.php
+++ b/src/Generic/Rules/FusionReplacePrototypeNameRector.php
@@ -25,10 +25,20 @@ public function getRuleDefinition(): RuleDefinition
public function refactorFileContent(string $fileContent): string
{
+ $comments = [];
foreach ($this->fusionPrototypeNameReplacements as $fusionPrototypeNameReplacement) {
+ $replacementCount = 0;
$pattern = '/(^|[=\s\(<\/])(' .$fusionPrototypeNameReplacement->oldName. ')([\s\{\)\/>]|$)/';
$replacement = '$1'.$fusionPrototypeNameReplacement->newName.'$3';
- $fileContent = preg_replace($pattern, $replacement, $fileContent);
+ $fileContent = preg_replace($pattern, $replacement, $fileContent, count: $replacementCount);
+
+ if($replacementCount > 0 && $fusionPrototypeNameReplacement->comment !== null) {
+ $comments[] = '// TODO 9.0 migration:' . $fusionPrototypeNameReplacement->comment;
+ }
+ }
+
+ if (count($comments) > 0){
+ $fileContent = implode("\n", $comments) . "\n" . $fileContent;
}
return $fileContent;
diff --git a/src/Generic/ValueObject/FusionPrototypeNameReplacement.php b/src/Generic/ValueObject/FusionPrototypeNameReplacement.php
index dec74a4..f60e47d 100644
--- a/src/Generic/ValueObject/FusionPrototypeNameReplacement.php
+++ b/src/Generic/ValueObject/FusionPrototypeNameReplacement.php
@@ -8,6 +8,7 @@ class FusionPrototypeNameReplacement
public function __construct(
public readonly string $oldName,
public readonly string $newName,
+ public readonly ?string $comment = null
) {
}
}
diff --git a/tests/Generic/Rules/FusionPrototypeNameReplacement/Fixture/some_file.fusion.inc b/tests/Generic/Rules/FusionPrototypeNameReplacement/Fixture/some_file.fusion.inc
index 63e2644..77f1105 100644
--- a/tests/Generic/Rules/FusionPrototypeNameReplacement/Fixture/some_file.fusion.inc
+++ b/tests/Generic/Rules/FusionPrototypeNameReplacement/Fixture/some_file.fusion.inc
@@ -6,6 +6,7 @@ prototype(Neos.Neos:SomethingOld) < prototype(Neos.Neos:Raw) {
renderer = Neos.Neos:Raw {
old = Neos.Neos:SomethingOld
+ older = Neos.Neos:SomethingOlder
renderer = afx`
@@ -15,6 +16,8 @@ prototype(Neos.Neos:SomethingOld) < prototype(Neos.Neos:Raw) {
}
}
-----
+// TODO 9.0 migration:Neos.Neos:Raw: This comment should be added on top of the file.
+// TODO 9.0 migration:Neos.Neos:SomethingOlder: This comment should be added on top of the file.
prototype(Neos.Neos:SomethingNew) < prototype(Neos.Neos:NewRaw) {
raw = Neos.Neos:NewRaw
@@ -23,6 +26,7 @@ prototype(Neos.Neos:SomethingNew) < prototype(Neos.Neos:NewRaw) {
renderer = Neos.Neos:NewRaw {
old = Neos.Neos:SomethingNew
+ older = Neos.Neos:SomethingNewer
renderer = afx`
diff --git a/tests/Generic/Rules/FusionPrototypeNameReplacement/config/configured_rule.php b/tests/Generic/Rules/FusionPrototypeNameReplacement/config/configured_rule.php
index 61b9ebe..740ee4e 100644
--- a/tests/Generic/Rules/FusionPrototypeNameReplacement/config/configured_rule.php
+++ b/tests/Generic/Rules/FusionPrototypeNameReplacement/config/configured_rule.php
@@ -17,7 +17,9 @@
$rectorConfig->disableParallel(); // does not work for fusion files - see https://github.com/rectorphp/rector-src/pull/2597#issuecomment-1190120688
$rectorConfig->ruleWithConfiguration(FusionReplacePrototypeNameRector::class, [
- new FusionPrototypeNameReplacement('Neos.Neos:Raw', 'Neos.Neos:NewRaw'),
+ new FusionPrototypeNameReplacement('Neos.Neos:Raw', 'Neos.Neos:NewRaw', 'Neos.Neos:Raw: This comment should be added on top of the file.'),
+ new FusionPrototypeNameReplacement('Neos.Neos:NotExisting', 'Neos.Neos:NewNotExisting', 'Neos.Neos:NotExisting: This comment should NOT be added on top of the file.'),
new FusionPrototypeNameReplacement('Neos.Neos:SomethingOld', 'Neos.Neos:SomethingNew'),
+ new FusionPrototypeNameReplacement('Neos.Neos:SomethingOlder', 'Neos.Neos:SomethingNewer', 'Neos.Neos:SomethingOlder: This comment should be added on top of the file.'),
]);
};