Skip to content

Commit

Permalink
NodeComparator::compareNodes rewritten for PHP 7.2 compatibility
Browse files Browse the repository at this point in the history
fixes #3
  • Loading branch information
dakujem committed Feb 27, 2018
1 parent 758d599 commit ce452cd
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Comparator/NodeComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,21 @@ protected function compareNodes(IDataNode $node1, IDataNode $node2, $recursive,
$childrenOfNode1 = $node1->getChildren();
$childrenOfNode2 = $node2->getChildren();
$same = count($childrenOfNode1) === count($childrenOfNode2);
while ($same && ($keyPair1 = each($childrenOfNode1)) && ($keyPair2 = each($childrenOfNode2))) {
while ($same && ($key1 = key($childrenOfNode1)) !== NULL && ($key2 = key($childrenOfNode2)) !== NULL) {
$same = $same &&
(!$compareChildIndices || ($strictness & self::STRICT_INDICES ? $keyPair1[0] === $keyPair2[0] : $keyPair1[0] == $keyPair2[0])) &&
$this->compareNodes($keyPair1[1], $keyPair2[1], $recursive, $strictness, $compareChildIndices, $compareNodeTypes, $compareFunction) // recursion
(!$compareChildIndices || ($strictness & self::STRICT_INDICES ? $key1 === $key2 : $key1 == $key2)) &&
$this->compareNodes(
current($childrenOfNode1), //
current($childrenOfNode2), //
$recursive, //
$strictness, //
$compareChildIndices, //
$compareNodeTypes, //
$compareFunction //
) // recursion
;
next($childrenOfNode1);
next($childrenOfNode2);
}
}
return $same && $compareFunction($node1->getContents(), $node2->getContents(), $strictness);
Expand Down

0 comments on commit ce452cd

Please sign in to comment.