diff --git a/src/PhpParser/Comparing/NodeComparator.php b/src/PhpParser/Comparing/NodeComparator.php index 0a9edd8a93a..fd568b4994b 100644 --- a/src/PhpParser/Comparing/NodeComparator.php +++ b/src/PhpParser/Comparing/NodeComparator.php @@ -35,28 +35,27 @@ public function printWithoutComments(Node | array | null $node): string */ public function areNodesEqual(Node | array | null $firstNode, Node | array | null $secondNode): bool { - if ($firstNode instanceof Node && $secondNode === null) { + if ($firstNode instanceof Node && !$secondNode instanceof Node) { return false; } - - if ($secondNode instanceof Node && $firstNode === null) { + if (!$firstNode instanceof Node && $secondNode instanceof Node) { return false; } if (is_array($firstNode)) { - Assert::allIsAOf($firstNode, Node::class); - - if ($secondNode === null) { + if (!is_array($secondNode)) { return false; } + + Assert::allIsAOf($firstNode, Node::class); } if (is_array($secondNode)) { - Assert::allIsAOf($secondNode, Node::class); - - if ($firstNode === null) { + if (!is_array($firstNode)) { return false; } + + Assert::allIsAOf($secondNode, Node::class); } return $this->printWithoutComments($firstNode) === $this->printWithoutComments($secondNode);