From c1d087a63b4f757c942d7444783acbeaca2775f9 Mon Sep 17 00:00:00 2001
From: Denny Lubitz <lubitz@vivomedia.de>
Date: Mon, 17 Jun 2024 11:25:14 +0200
Subject: [PATCH] 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(