Skip to content

Commit 6ea687d

Browse files
committed
AC-3483:: SVC false-positive: modifying system.xml file from another module
1 parent cec6352 commit 6ea687d

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

src/Analyzer/SystemXml/Analyzer.php

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,34 @@ private function reportAddedNodesWithDuplicateCheck($afterFile, $addedNodes, $mo
143143
*/
144144
private function isDuplicateNode($node, $existingNode)
145145
{
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');
150151

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);
153174
}
154175

155176
/**

0 commit comments

Comments
 (0)