From faf1aba8717833445a094988aec14feb69aaa961 Mon Sep 17 00:00:00 2001 From: Denny Lubitz Date: Sun, 2 Jun 2024 13:38:52 +0200 Subject: [PATCH 1/8] Bugfix rewrite of q(node).property('_contextPath') --- .../Rules/FusionNodeContextPathRector.php | 4 ++-- .../Fixture/some_file.fusion.inc | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ContentRepository90/Rules/FusionNodeContextPathRector.php b/src/ContentRepository90/Rules/FusionNodeContextPathRector.php index b96f9b9..73ea60e 100644 --- a/src/ContentRepository90/Rules/FusionNodeContextPathRector.php +++ b/src/ContentRepository90/Rules/FusionNodeContextPathRector.php @@ -30,13 +30,13 @@ public function refactorFileContent(string $fileContent): string '// TODO 9.0 migration: Line %LINE: !! You very likely need to rewrite "VARIABLE.contextPath" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->process(fn(string $eelExpression) => preg_replace( - '/(node|documentNode|site)\.property\\((\'|")_contextPath(\'|")\\)/', + '/q\((node|documentNode|site)\)\.property\\((\'|")_contextPath(\'|")\\)/', 'Neos.Node.serializedNodeAddress($1)', $eelExpression )) ->addCommentsIfRegexMatches( '/\.property\\((\'|")_contextPath(\'|")\\)/', - '// TODO 9.0 migration: Line %LINE: !! You very likely need to rewrite "VARIABLE.property(\'_contextPath\')" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' + '// TODO 9.0 migration: Line %LINE: !! You very likely need to rewrite "q(VARIABLE).property(\'_contextPath\')" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->getProcessedContent(); } diff --git a/tests/ContentRepository90/Rules/FusionNodeContextPathRector/Fixture/some_file.fusion.inc b/tests/ContentRepository90/Rules/FusionNodeContextPathRector/Fixture/some_file.fusion.inc index 32cc7be..67833e0 100644 --- a/tests/ContentRepository90/Rules/FusionNodeContextPathRector/Fixture/some_file.fusion.inc +++ b/tests/ContentRepository90/Rules/FusionNodeContextPathRector/Fixture/some_file.fusion.inc @@ -5,8 +5,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie # # pass down props # - attributes = ${node.contextPath || documentNode.contextPath || node.property('_contextPath') || documentNode.property("_contextPath")} - foo = ${bar.property('_contextPath') || bar.property("_contextPath")} + attributes = ${node.contextPath || documentNode.contextPath || q(node).property('_contextPath') || q(documentNode).property("_contextPath")} + foo = ${q(bar).property('_contextPath') || q(bar).property("_contextPath")} # # the `checked` state is calculated outside the renderer to allow` overriding via `attributes` @@ -31,7 +31,7 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie } } ----- -// TODO 9.0 migration: Line 11: !! You very likely need to rewrite "VARIABLE.property('_contextPath')" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node. +// TODO 9.0 migration: Line 11: !! You very likely need to rewrite "q(VARIABLE).property('_contextPath')" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node. // TODO 9.0 migration: Line 27: !! You very likely need to rewrite "VARIABLE.contextPath" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node. prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Field) { @@ -41,7 +41,7 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie # pass down props # attributes = ${Neos.Node.serializedNodeAddress(node) || Neos.Node.serializedNodeAddress(documentNode) || Neos.Node.serializedNodeAddress(node) || Neos.Node.serializedNodeAddress(documentNode)} - foo = ${bar.property('_contextPath') || bar.property("_contextPath")} + foo = ${q(bar).property('_contextPath') || q(bar).property("_contextPath")} # # the `checked` state is calculated outside the renderer to allow` overriding via `attributes` From 55dce1f75d9f79494ed09e7b62072aa22335c274 Mon Sep 17 00:00:00 2001 From: Denny Lubitz Date: Sun, 2 Jun 2024 13:55:54 +0200 Subject: [PATCH 2/8] Bugfix rewrite of q(node).property('_depth') --- src/ContentRepository90/Rules/FusionNodeDepthRector.php | 8 ++++---- .../FusionNodeDepthRector/Fixture/some_file.fusion.inc | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ContentRepository90/Rules/FusionNodeDepthRector.php b/src/ContentRepository90/Rules/FusionNodeDepthRector.php index 54a67e3..0c51768 100644 --- a/src/ContentRepository90/Rules/FusionNodeDepthRector.php +++ b/src/ContentRepository90/Rules/FusionNodeDepthRector.php @@ -14,7 +14,7 @@ class FusionNodeDepthRector implements FusionRectorInterface public function getRuleDefinition(): RuleDefinition { - return CodeSampleLoader::fromFile('Fusion: Rewrite node.depth to Neos.Node.depth(node)', __CLASS__); + return CodeSampleLoader::fromFile('Fusion: Rewrite node.depth and q(node).property("_depth") to Neos.Node.depth(node)', __CLASS__); } public function refactorFileContent(string $fileContent): string @@ -30,13 +30,13 @@ public function refactorFileContent(string $fileContent): string '// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.depth" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->process(fn(string $eelExpression) => preg_replace( - '/([a-zA-Z.]+)?(node|documentNode)\.property\\((\'|")_depth(\'|")\\)/', - 'Neos.Node.depth($1$2)', + '/q\((node|documentNode)\)\.property\\((\'|")_depth(\'|")\\)/', + 'Neos.Node.depth($1)', $eelExpression )) ->addCommentsIfRegexMatches( '/\.property\\((\'|")_depth(\'|")\\)/', - '// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.property(\'_depth\')" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' + '// TODO 9.0 migration: Line %LINE: You may need to rewrite "q(VARIABLE).property(\'_depth\')" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' )->getProcessedContent(); } } diff --git a/tests/ContentRepository90/Rules/FusionNodeDepthRector/Fixture/some_file.fusion.inc b/tests/ContentRepository90/Rules/FusionNodeDepthRector/Fixture/some_file.fusion.inc index 9e4cbf3..d2407d3 100644 --- a/tests/ContentRepository90/Rules/FusionNodeDepthRector/Fixture/some_file.fusion.inc +++ b/tests/ContentRepository90/Rules/FusionNodeDepthRector/Fixture/some_file.fusion.inc @@ -5,8 +5,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie # # pass down props # - attributes = ${node.depth || documentNode.depth || node.property('_depth') || documentNode.property("_depth")} - foo = ${bar.property('_depth') || bar.property("_depth")} + attributes = ${node.depth || documentNode.depth || q(node).property('_depth') || q(documentNode).property("_depth")} + foo = ${q(bar).property('_depth') || q(bar).property("_depth")} # # the `checked` state is calculated outside the renderer to allow` overriding via `attributes` @@ -31,7 +31,7 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie } } ----- -// TODO 9.0 migration: Line 11: You may need to rewrite "VARIABLE.property('_depth')" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node. +// TODO 9.0 migration: Line 11: You may need to rewrite "q(VARIABLE).property('_depth')" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node. // TODO 9.0 migration: Line 27: You may need to rewrite "VARIABLE.depth" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node. prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Field) { @@ -41,7 +41,7 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie # pass down props # attributes = ${Neos.Node.depth(node) || Neos.Node.depth(documentNode) || Neos.Node.depth(node) || Neos.Node.depth(documentNode)} - foo = ${bar.property('_depth') || bar.property("_depth")} + foo = ${q(bar).property('_depth') || q(bar).property("_depth")} # # the `checked` state is calculated outside the renderer to allow` overriding via `attributes` From eb57070a72a31df3dc38b0700bdf3fa4df8210b9 Mon Sep 17 00:00:00 2001 From: Denny Lubitz Date: Sun, 2 Jun 2024 14:04:06 +0200 Subject: [PATCH 3/8] Bugfix rewrite of q(node).property('_hiddenInIndex') --- .../Rules/FusionNodeHiddenInIndexRector.php | 11 ++++------- .../Fixture/some_file.fusion.inc | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php b/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php index 735c381..1d939bd 100644 --- a/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php +++ b/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php @@ -14,7 +14,7 @@ class FusionNodeHiddenInIndexRector implements FusionRectorInterface public function getRuleDefinition(): RuleDefinition { - return CodeSampleLoader::fromFile('Fusion: Rewrite node.hiddenInIndex to node.property(\'hiddenInIndex\')', __CLASS__); + return CodeSampleLoader::fromFile('Fusion: Rewrite node.hiddenInIndex and q(node).property("_hiddenInIndex") to node.property(\'hiddenInIndex\')', __CLASS__); } public function refactorFileContent(string $fileContent): string @@ -30,13 +30,10 @@ public function refactorFileContent(string $fileContent): string '// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.hiddenInIndex" to VARIABLE.property(\'hiddenInIndex\'). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->process(fn(string $eelExpression) => preg_replace( - '/([a-zA-Z.]+(node|documentNode))\.property\\(\'_hiddenInIndex\'\\)/', - '$1.property(\'hiddenInIndex\')', + '/\.property\\((\'|")_hiddenInIndex(\'|")\\)/', + '.property(\'hiddenInIndex\')', $eelExpression - )) - ->addCommentsIfRegexMatches( - '/\.property\\(\'_hiddenInIndex\'\\)/', - '// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.property(\'_hiddenInIndex\')" to VARIABLE.property(\'hiddenInIndex\'). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' + ) )->getProcessedContent(); } } diff --git a/tests/ContentRepository90/Rules/FusionNodeHiddenInIndexRector/Fixture/some_file.fusion.inc b/tests/ContentRepository90/Rules/FusionNodeHiddenInIndexRector/Fixture/some_file.fusion.inc index 99f65c0..b88d589 100644 --- a/tests/ContentRepository90/Rules/FusionNodeHiddenInIndexRector/Fixture/some_file.fusion.inc +++ b/tests/ContentRepository90/Rules/FusionNodeHiddenInIndexRector/Fixture/some_file.fusion.inc @@ -5,7 +5,7 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie # # pass down props # - attributes = ${node.hiddenInIndex || documentNode.hiddenInIndex || site.hiddenInIndex} + attributes = ${node.hiddenInIndex || documentNode.hiddenInIndex || site.hiddenInIndex || q(node).property('_hiddenInIndex') || q(documentNode).property("_hiddenInIndex")} # # the `checked` state is calculated outside the renderer to allow` overriding via `attributes` @@ -38,7 +38,7 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie # # pass down props # - attributes = ${node.property('hiddenInIndex') || documentNode.property('hiddenInIndex') || site.property('hiddenInIndex')} + attributes = ${node.property('hiddenInIndex') || documentNode.property('hiddenInIndex') || site.property('hiddenInIndex') || q(node).property('hiddenInIndex') || q(documentNode).property('hiddenInIndex')} # # the `checked` state is calculated outside the renderer to allow` overriding via `attributes` From 6a013de52d97499b69592b0dc2e94b1d9b141368 Mon Sep 17 00:00:00 2001 From: Denny Lubitz Date: Sun, 2 Jun 2024 14:09:44 +0200 Subject: [PATCH 4/8] Bugfix rewrite of q(node).property('_path') --- src/ContentRepository90/Rules/FusionNodePathRector.php | 10 +++------- .../FusionNodePathRector/Fixture/some_file.fusion.inc | 4 ++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/ContentRepository90/Rules/FusionNodePathRector.php b/src/ContentRepository90/Rules/FusionNodePathRector.php index 5ccc84e..6e08067 100644 --- a/src/ContentRepository90/Rules/FusionNodePathRector.php +++ b/src/ContentRepository90/Rules/FusionNodePathRector.php @@ -14,7 +14,7 @@ class FusionNodePathRector implements FusionRectorInterface public function getRuleDefinition(): RuleDefinition { - return CodeSampleLoader::fromFile('Fusion: Rewrite node.path to Neos.Node.path(node)', __CLASS__); + return CodeSampleLoader::fromFile('Fusion: Rewrite node.path and q(node).property("_path") to Neos.Node.path(node)', __CLASS__); } public function refactorFileContent(string $fileContent): string @@ -30,14 +30,10 @@ public function refactorFileContent(string $fileContent): string '// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.path" to Neos.Node.path(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->process(fn(string $eelExpression) => preg_replace( - '/(node|documentNode|site)\.property\\(\'_path\'\\)/', + '/q\((node|documentNode|site)\)\.property\\((\'|")_path(\'|")\\)/', 'Neos.Node.path($1)', $eelExpression - )) - ->addCommentsIfRegexMatches( - '/\.property\\(\'_path\'\\)/', - '// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.property(\'_path\')" to Neos.Node.path(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) - ->getProcessedContent(); + )->getProcessedContent(); } } diff --git a/tests/ContentRepository90/Rules/FusionNodePathRector/Fixture/some_file.fusion.inc b/tests/ContentRepository90/Rules/FusionNodePathRector/Fixture/some_file.fusion.inc index d6db00e..c127aa0 100644 --- a/tests/ContentRepository90/Rules/FusionNodePathRector/Fixture/some_file.fusion.inc +++ b/tests/ContentRepository90/Rules/FusionNodePathRector/Fixture/some_file.fusion.inc @@ -5,7 +5,7 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie # # pass down props # - attributes = ${node.path || documentNode.path} + attributes = ${node.path || documentNode.path || q(node).property('_path') || q(documentNode).property("_path")} # # the `checked` state is calculated outside the renderer to allow` overriding via `attributes` @@ -38,7 +38,7 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie # # pass down props # - attributes = ${Neos.Node.path(node) || Neos.Node.path(documentNode)} + attributes = ${Neos.Node.path(node) || Neos.Node.path(documentNode) || Neos.Node.path(node) || Neos.Node.path(documentNode)} # # the `checked` state is calculated outside the renderer to allow` overriding via `attributes` From 29b338615e7eda32c172b523039c59bd2d2baee3 Mon Sep 17 00:00:00 2001 From: Denny Lubitz Date: Thu, 13 Jun 2024 09:58:35 +0200 Subject: [PATCH 5/8] TASK Simplify regex and relax pattern --- .../Rules/FusionNodeContextPathRector.php | 4 ++-- .../Rules/FusionNodeDepthRector.php | 8 ++++---- .../Rules/FusionNodeHiddenInIndexRector.php | 4 ++-- .../Rules/FusionNodePathRector.php | 4 ++-- .../Fixture/some_file.fusion.inc | 8 +++++--- .../Fixture/some_file.fusion.inc | 15 ++++++++++----- .../Fixture/some_file.fusion.inc | 13 ++++++++++--- 7 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/ContentRepository90/Rules/FusionNodeContextPathRector.php b/src/ContentRepository90/Rules/FusionNodeContextPathRector.php index 73ea60e..cd33941 100644 --- a/src/ContentRepository90/Rules/FusionNodeContextPathRector.php +++ b/src/ContentRepository90/Rules/FusionNodeContextPathRector.php @@ -30,12 +30,12 @@ public function refactorFileContent(string $fileContent): string '// TODO 9.0 migration: Line %LINE: !! You very likely need to rewrite "VARIABLE.contextPath" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->process(fn(string $eelExpression) => preg_replace( - '/q\((node|documentNode|site)\)\.property\\((\'|")_contextPath(\'|")\\)/', + '/q\(([^)]+)\)\.property\([\'"]_contextPath[\'"]\)/', 'Neos.Node.serializedNodeAddress($1)', $eelExpression )) ->addCommentsIfRegexMatches( - '/\.property\\((\'|")_contextPath(\'|")\\)/', + '/\.property\([\'"]_contextPath[\'"]\)/', '// TODO 9.0 migration: Line %LINE: !! You very likely need to rewrite "q(VARIABLE).property(\'_contextPath\')" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->getProcessedContent(); diff --git a/src/ContentRepository90/Rules/FusionNodeDepthRector.php b/src/ContentRepository90/Rules/FusionNodeDepthRector.php index 0c51768..b400035 100644 --- a/src/ContentRepository90/Rules/FusionNodeDepthRector.php +++ b/src/ContentRepository90/Rules/FusionNodeDepthRector.php @@ -21,21 +21,21 @@ public function refactorFileContent(string $fileContent): string { return EelExpressionTransformer::parse($fileContent) ->process(fn(string $eelExpression) => preg_replace( - '/([a-zA-Z.]+)?(node|documentNode)\.depth/', + '/([a-zA-Z.]+)?(site|node|documentNode)\.depth/', 'Neos.Node.depth($1$2)', $eelExpression )) ->addCommentsIfRegexMatches( - '/\.depth$/', + '/\.depth([^(]|$)/', '// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.depth" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->process(fn(string $eelExpression) => preg_replace( - '/q\((node|documentNode)\)\.property\\((\'|")_depth(\'|")\\)/', + '/q\(([^)]+)\)\.property\([\'"]_depth[\'"]\)/', 'Neos.Node.depth($1)', $eelExpression )) ->addCommentsIfRegexMatches( - '/\.property\\((\'|")_depth(\'|")\\)/', + '/\.property\([\'"]_depth[\'"]\)/', '// TODO 9.0 migration: Line %LINE: You may need to rewrite "q(VARIABLE).property(\'_depth\')" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' )->getProcessedContent(); } diff --git a/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php b/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php index 1d939bd..c5603c8 100644 --- a/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php +++ b/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php @@ -26,11 +26,11 @@ public function refactorFileContent(string $fileContent): string $eelExpression )) ->addCommentsIfRegexMatches( - '/\.hiddenInIndex/', + '/\.hiddenInIndex$/', '// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.hiddenInIndex" to VARIABLE.property(\'hiddenInIndex\'). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->process(fn(string $eelExpression) => preg_replace( - '/\.property\\((\'|")_hiddenInIndex(\'|")\\)/', + '/\.property\([^)]+_hiddenInIndex[^)]+\)/', '.property(\'hiddenInIndex\')', $eelExpression ) diff --git a/src/ContentRepository90/Rules/FusionNodePathRector.php b/src/ContentRepository90/Rules/FusionNodePathRector.php index 6e08067..a5af08b 100644 --- a/src/ContentRepository90/Rules/FusionNodePathRector.php +++ b/src/ContentRepository90/Rules/FusionNodePathRector.php @@ -26,11 +26,11 @@ public function refactorFileContent(string $fileContent): string $eelExpression )) ->addCommentsIfRegexMatches( - '/\.path$/', + '/\.path([^(]|$)/', '// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.path" to Neos.Node.path(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->process(fn(string $eelExpression) => preg_replace( - '/q\((node|documentNode|site)\)\.property\\((\'|")_path(\'|")\\)/', + '/q\(([^)]+)\)\.property\([^)]+_path[^)]+\)/', 'Neos.Node.path($1)', $eelExpression ) diff --git a/tests/ContentRepository90/Rules/FusionNodeContextPathRector/Fixture/some_file.fusion.inc b/tests/ContentRepository90/Rules/FusionNodeContextPathRector/Fixture/some_file.fusion.inc index 67833e0..ee8a622 100644 --- a/tests/ContentRepository90/Rules/FusionNodeContextPathRector/Fixture/some_file.fusion.inc +++ b/tests/ContentRepository90/Rules/FusionNodeContextPathRector/Fixture/some_file.fusion.inc @@ -7,6 +7,7 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie # attributes = ${node.contextPath || documentNode.contextPath || q(node).property('_contextPath') || q(documentNode).property("_contextPath")} foo = ${q(bar).property('_contextPath') || q(bar).property("_contextPath")} + boo = ${q(nodes).first().property('_contextPath') || q(nodes).first().property("_contextPath")} # # the `checked` state is calculated outside the renderer to allow` overriding via `attributes` @@ -31,8 +32,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie } } ----- -// TODO 9.0 migration: Line 11: !! You very likely need to rewrite "q(VARIABLE).property('_contextPath')" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node. -// TODO 9.0 migration: Line 27: !! You very likely need to rewrite "VARIABLE.contextPath" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node. +// TODO 9.0 migration: Line 12: !! You very likely need to rewrite "q(VARIABLE).property('_contextPath')" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node. +// TODO 9.0 migration: Line 28: !! You very likely need to rewrite "VARIABLE.contextPath" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node. prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Field) { renderer = Neos.Fusion:Component { @@ -41,7 +42,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie # pass down props # attributes = ${Neos.Node.serializedNodeAddress(node) || Neos.Node.serializedNodeAddress(documentNode) || Neos.Node.serializedNodeAddress(node) || Neos.Node.serializedNodeAddress(documentNode)} - foo = ${q(bar).property('_contextPath') || q(bar).property("_contextPath")} + foo = ${Neos.Node.serializedNodeAddress(bar) || Neos.Node.serializedNodeAddress(bar)} + boo = ${q(nodes).first().property('_contextPath') || q(nodes).first().property("_contextPath")} # # the `checked` state is calculated outside the renderer to allow` overriding via `attributes` diff --git a/tests/ContentRepository90/Rules/FusionNodeDepthRector/Fixture/some_file.fusion.inc b/tests/ContentRepository90/Rules/FusionNodeDepthRector/Fixture/some_file.fusion.inc index d2407d3..fb608fe 100644 --- a/tests/ContentRepository90/Rules/FusionNodeDepthRector/Fixture/some_file.fusion.inc +++ b/tests/ContentRepository90/Rules/FusionNodeDepthRector/Fixture/some_file.fusion.inc @@ -7,6 +7,7 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie # attributes = ${node.depth || documentNode.depth || q(node).property('_depth') || q(documentNode).property("_depth")} foo = ${q(bar).property('_depth') || q(bar).property("_depth")} + boo = ${q(nodes).first().property('_depth') || q(nodes).first().property("_depth")} # # the `checked` state is calculated outside the renderer to allow` overriding via `attributes` @@ -23,7 +24,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie @@ -31,8 +33,9 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie } } ----- -// TODO 9.0 migration: Line 11: You may need to rewrite "q(VARIABLE).property('_depth')" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node. -// TODO 9.0 migration: Line 27: You may need to rewrite "VARIABLE.depth" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node. +// TODO 9.0 migration: Line 13: You may need to rewrite "q(VARIABLE).property('_depth')" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node. +// TODO 9.0 migration: Line 29: You may need to rewrite "VARIABLE.depth" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node. +// TODO 9.0 migration: Line 30: You may need to rewrite "VARIABLE.depth" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node. prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Field) { renderer = Neos.Fusion:Component { @@ -41,7 +44,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie # pass down props # attributes = ${Neos.Node.depth(node) || Neos.Node.depth(documentNode) || Neos.Node.depth(node) || Neos.Node.depth(documentNode)} - foo = ${q(bar).property('_depth') || q(bar).property("_depth")} + foo = ${Neos.Node.depth(bar) || Neos.Node.depth(bar)} + boo = ${q(nodes).first().property('_depth') || q(nodes).first().property("_depth")} # # the `checked` state is calculated outside the renderer to allow` overriding via `attributes` @@ -58,7 +62,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie diff --git a/tests/ContentRepository90/Rules/FusionNodePathRector/Fixture/some_file.fusion.inc b/tests/ContentRepository90/Rules/FusionNodePathRector/Fixture/some_file.fusion.inc index c127aa0..01ff46b 100644 --- a/tests/ContentRepository90/Rules/FusionNodePathRector/Fixture/some_file.fusion.inc +++ b/tests/ContentRepository90/Rules/FusionNodePathRector/Fixture/some_file.fusion.inc @@ -6,6 +6,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie # pass down props # attributes = ${node.path || documentNode.path || q(node).property('_path') || q(documentNode).property("_path")} + foo = ${q(bar).property('_path') || q(bar).property("_path")} + boo = ${q(nodes).first().property('_path') || q(nodes).first().property("_path")} # # the `checked` state is calculated outside the renderer to allow` overriding via `attributes` @@ -22,7 +24,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie @@ -30,7 +33,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie } } ----- -// TODO 9.0 migration: Line 26: You may need to rewrite "VARIABLE.path" to Neos.Node.path(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node. +// TODO 9.0 migration: Line 29: You may need to rewrite "VARIABLE.path" to Neos.Node.path(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node. +// TODO 9.0 migration: Line 30: You may need to rewrite "VARIABLE.path" to Neos.Node.path(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node. prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Field) { renderer = Neos.Fusion:Component { @@ -39,6 +43,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie # pass down props # attributes = ${Neos.Node.path(node) || Neos.Node.path(documentNode) || Neos.Node.path(node) || Neos.Node.path(documentNode)} + foo = ${Neos.Node.path(bar) || Neos.Node.path(bar)} + boo = ${q(nodes).first().property('_path') || q(nodes).first().property("_path")} # # the `checked` state is calculated outside the renderer to allow` overriding via `attributes` @@ -55,7 +61,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie From c1d087a63b4f757c942d7444783acbeaca2775f9 Mon Sep 17 00:00:00 2001 From: Denny Lubitz Date: Mon, 17 Jun 2024 11:25:14 +0200 Subject: [PATCH 6/8] BUGFIX Regex for fetching node properties --- .../Rules/FusionNodeContextPathRector.php | 6 +++--- src/ContentRepository90/Rules/FusionNodeDepthRector.php | 6 +++--- .../Rules/FusionNodeHiddenInIndexRector.php | 6 +++--- src/ContentRepository90/Rules/FusionNodePathRector.php | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ContentRepository90/Rules/FusionNodeContextPathRector.php b/src/ContentRepository90/Rules/FusionNodeContextPathRector.php index cd33941..e9b4707 100644 --- a/src/ContentRepository90/Rules/FusionNodeContextPathRector.php +++ b/src/ContentRepository90/Rules/FusionNodeContextPathRector.php @@ -21,12 +21,12 @@ public function refactorFileContent(string $fileContent): string { return EelExpressionTransformer::parse($fileContent) ->process(fn(string $eelExpression) => preg_replace( - '/(node|documentNode|site)\.contextPath/', - 'Neos.Node.serializedNodeAddress($1)', + '/(node|documentNode|site)\.contextPath([^\w(]|$)/', + 'Neos.Node.serializedNodeAddress($1)$2', $eelExpression )) ->addCommentsIfRegexMatches( - '/\.contextPath/', + '/\.contextPath([^\w(]|$)/', '// TODO 9.0 migration: Line %LINE: !! You very likely need to rewrite "VARIABLE.contextPath" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->process(fn(string $eelExpression) => preg_replace( diff --git a/src/ContentRepository90/Rules/FusionNodeDepthRector.php b/src/ContentRepository90/Rules/FusionNodeDepthRector.php index b400035..314a413 100644 --- a/src/ContentRepository90/Rules/FusionNodeDepthRector.php +++ b/src/ContentRepository90/Rules/FusionNodeDepthRector.php @@ -21,12 +21,12 @@ public function refactorFileContent(string $fileContent): string { return EelExpressionTransformer::parse($fileContent) ->process(fn(string $eelExpression) => preg_replace( - '/([a-zA-Z.]+)?(site|node|documentNode)\.depth/', - 'Neos.Node.depth($1$2)', + '/([a-zA-Z.]+)?(site|node|documentNode)\.depth([^\w(]|$)/', + 'Neos.Node.depth($1$2)$3', $eelExpression )) ->addCommentsIfRegexMatches( - '/\.depth([^(]|$)/', + '/\.depth([^\w(]|$)/', '// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.depth" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->process(fn(string $eelExpression) => preg_replace( diff --git a/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php b/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php index c5603c8..1f3b40d 100644 --- a/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php +++ b/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php @@ -21,12 +21,12 @@ public function refactorFileContent(string $fileContent): string { return EelExpressionTransformer::parse($fileContent) ->process(fn(string $eelExpression) => preg_replace( - '/(node|documentNode|site)\.hiddenInIndex/', - '$1.property(\'hiddenInIndex\')', + '/(node|documentNode|site)\.hiddenInIndex([^\w(]|$)/', + '$1.property(\'hiddenInIndex\')$2', $eelExpression )) ->addCommentsIfRegexMatches( - '/\.hiddenInIndex$/', + '/\.hiddenInIndex([^\w(]|$)/', '// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.hiddenInIndex" to VARIABLE.property(\'hiddenInIndex\'). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->process(fn(string $eelExpression) => preg_replace( diff --git a/src/ContentRepository90/Rules/FusionNodePathRector.php b/src/ContentRepository90/Rules/FusionNodePathRector.php index a5af08b..2672d72 100644 --- a/src/ContentRepository90/Rules/FusionNodePathRector.php +++ b/src/ContentRepository90/Rules/FusionNodePathRector.php @@ -21,12 +21,12 @@ public function refactorFileContent(string $fileContent): string { return EelExpressionTransformer::parse($fileContent) ->process(fn(string $eelExpression) => preg_replace( - '/(node|documentNode|site)\.path/', - 'Neos.Node.path($1)', + '/(node|documentNode|site)\.path([^\w(]|$)/', + 'Neos.Node.path($1)$2', $eelExpression )) ->addCommentsIfRegexMatches( - '/\.path([^(]|$)/', + '/\.path([^\w(]|$)/', '// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.path" to Neos.Node.path(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->process(fn(string $eelExpression) => preg_replace( From 03dba3fb9426af10bf5b1db39689c5847281cc07 Mon Sep 17 00:00:00 2001 From: Denny Lubitz Date: Mon, 17 Jun 2024 12:20:20 +0200 Subject: [PATCH 7/8] BUGFIX Regex for fetching node properties --- .../Rules/FusionNodeContextPathRector.php | 6 +++--- src/ContentRepository90/Rules/FusionNodeDepthRector.php | 6 +++--- .../Rules/FusionNodeHiddenInIndexRector.php | 6 +++--- src/ContentRepository90/Rules/FusionNodePathRector.php | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ContentRepository90/Rules/FusionNodeContextPathRector.php b/src/ContentRepository90/Rules/FusionNodeContextPathRector.php index e9b4707..8fa66d8 100644 --- a/src/ContentRepository90/Rules/FusionNodeContextPathRector.php +++ b/src/ContentRepository90/Rules/FusionNodeContextPathRector.php @@ -21,12 +21,12 @@ public function refactorFileContent(string $fileContent): string { return EelExpressionTransformer::parse($fileContent) ->process(fn(string $eelExpression) => preg_replace( - '/(node|documentNode|site)\.contextPath([^\w(]|$)/', - 'Neos.Node.serializedNodeAddress($1)$2', + '/(node|documentNode|site)\.contextPath\b(?!\.|\()/', + 'Neos.Node.serializedNodeAddress($1)', $eelExpression )) ->addCommentsIfRegexMatches( - '/\.contextPath([^\w(]|$)/', + '/\.contextPath\b(?!\.|\()/', '// TODO 9.0 migration: Line %LINE: !! You very likely need to rewrite "VARIABLE.contextPath" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->process(fn(string $eelExpression) => preg_replace( diff --git a/src/ContentRepository90/Rules/FusionNodeDepthRector.php b/src/ContentRepository90/Rules/FusionNodeDepthRector.php index 314a413..9a0f8d1 100644 --- a/src/ContentRepository90/Rules/FusionNodeDepthRector.php +++ b/src/ContentRepository90/Rules/FusionNodeDepthRector.php @@ -21,12 +21,12 @@ public function refactorFileContent(string $fileContent): string { return EelExpressionTransformer::parse($fileContent) ->process(fn(string $eelExpression) => preg_replace( - '/([a-zA-Z.]+)?(site|node|documentNode)\.depth([^\w(]|$)/', - 'Neos.Node.depth($1$2)$3', + '/([a-zA-Z.]+)?(site|node|documentNode)\.depth\b(?!\.|\()/', + 'Neos.Node.depth($1$2)', $eelExpression )) ->addCommentsIfRegexMatches( - '/\.depth([^\w(]|$)/', + '/\.depth\b(?!\.|\()/', '// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.depth" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->process(fn(string $eelExpression) => preg_replace( diff --git a/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php b/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php index 1f3b40d..8d639fd 100644 --- a/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php +++ b/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php @@ -21,12 +21,12 @@ public function refactorFileContent(string $fileContent): string { return EelExpressionTransformer::parse($fileContent) ->process(fn(string $eelExpression) => preg_replace( - '/(node|documentNode|site)\.hiddenInIndex([^\w(]|$)/', - '$1.property(\'hiddenInIndex\')$2', + '/(node|documentNode|site)\.hiddenInIndex\b(?!\.|\()/', + '$1.property(\'hiddenInIndex\')', $eelExpression )) ->addCommentsIfRegexMatches( - '/\.hiddenInIndex([^\w(]|$)/', + '/\.hiddenInIndex\b(?!\.|\()/', '// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.hiddenInIndex" to VARIABLE.property(\'hiddenInIndex\'). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->process(fn(string $eelExpression) => preg_replace( diff --git a/src/ContentRepository90/Rules/FusionNodePathRector.php b/src/ContentRepository90/Rules/FusionNodePathRector.php index 2672d72..b0d2efe 100644 --- a/src/ContentRepository90/Rules/FusionNodePathRector.php +++ b/src/ContentRepository90/Rules/FusionNodePathRector.php @@ -21,12 +21,12 @@ public function refactorFileContent(string $fileContent): string { return EelExpressionTransformer::parse($fileContent) ->process(fn(string $eelExpression) => preg_replace( - '/(node|documentNode|site)\.path([^\w(]|$)/', - 'Neos.Node.path($1)$2', + '/(node|documentNode|site)\.path\b(?!\.|\()/', + 'Neos.Node.path($1)', $eelExpression )) ->addCommentsIfRegexMatches( - '/\.path([^\w(]|$)/', + '/\.path\b(?!\.|\()/', '// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.path" to Neos.Node.path(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->process(fn(string $eelExpression) => preg_replace( From 9f5a97e64374ac2c37094f802090c9fec9fcd27f Mon Sep 17 00:00:00 2001 From: Denny Lubitz Date: Mon, 17 Jun 2024 13:14:53 +0200 Subject: [PATCH 8/8] BUGFIX Regex for fetching node properties --- src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php | 2 +- src/ContentRepository90/Rules/FusionNodePathRector.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php b/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php index 8d639fd..92c9869 100644 --- a/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php +++ b/src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php @@ -30,7 +30,7 @@ public function refactorFileContent(string $fileContent): string '// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.hiddenInIndex" to VARIABLE.property(\'hiddenInIndex\'). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->process(fn(string $eelExpression) => preg_replace( - '/\.property\([^)]+_hiddenInIndex[^)]+\)/', + '/\.property\([\'"]_hiddenInIndex[\'"]\)/', '.property(\'hiddenInIndex\')', $eelExpression ) diff --git a/src/ContentRepository90/Rules/FusionNodePathRector.php b/src/ContentRepository90/Rules/FusionNodePathRector.php index b0d2efe..ddbc120 100644 --- a/src/ContentRepository90/Rules/FusionNodePathRector.php +++ b/src/ContentRepository90/Rules/FusionNodePathRector.php @@ -30,7 +30,7 @@ public function refactorFileContent(string $fileContent): string '// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.path" to Neos.Node.path(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.' ) ->process(fn(string $eelExpression) => preg_replace( - '/q\(([^)]+)\)\.property\([^)]+_path[^)]+\)/', + '/q\(([^)]+)\)\.property\([\'"]_path[\'"]\)/', 'Neos.Node.path($1)', $eelExpression )