@@ -143,13 +143,34 @@ private function reportAddedNodesWithDuplicateCheck($afterFile, $addedNodes, $mo
143
143
*/
144
144
private function isDuplicateNode ($ node , $ existingNode )
145
145
{
146
- $ nodeData = $ node ->data ;
147
- $ existingNodeData = $ existingNode ->data ;
148
- // Remove 'id' key for comparison
149
- unset($ nodeData ['id ' ], $ existingNodeData ['id ' ]);
146
+ // Access the 'id' properties using possible getter methods
147
+ //Testing file
148
+
149
+ $ nodeId = $ this ->getPrivateProperty ($ node , 'id ' );
150
+ $ existingNodeId = $ this ->getPrivateProperty ($ existingNode , 'id ' );
150
151
151
- // Compare the remaining parts of the nodes
152
- return $ node == $ existingNode ;
152
+ // Access 'parent' properties if needed, depending on your logic
153
+ $ nodeParent = $ this ->getPrivateProperty ($ node , 'parent ' );
154
+ $ existingNodeParent = $ this ->getPrivateProperty ($ existingNode , 'parent ' );
155
+
156
+ // Compare the nodes after ignoring 'id'
157
+ return $ nodeParent == $ existingNodeParent ;
158
+ }
159
+
160
+ /**
161
+ * Simplifies the reflection to get property
162
+ *
163
+ * @param $object
164
+ * @param $propertyName
165
+ * @return mixed
166
+ * @throws \ReflectionException
167
+ */
168
+ private function getPrivateProperty ($ object , $ propertyName )
169
+ {
170
+ $ reflection = new \ReflectionClass ($ object );
171
+ $ property = $ reflection ->getProperty ($ propertyName );
172
+ $ property ->setAccessible (true );
173
+ return $ property ->getValue ($ object );
153
174
}
154
175
155
176
/**
0 commit comments