From 856130a2131588dd6680d1c597e5fdf8434e6937 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 21 Oct 2026 23:30:10 +0200 Subject: [PATCH] use Node|null in \Rector\PhpParser\Comparing\NodeComparator::areNodesEqual() --- src/PhpParser/Comparing/NodeComparator.php | 32 +++------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/src/PhpParser/Comparing/NodeComparator.php b/src/PhpParser/Comparing/NodeComparator.php index 918117e680d..86fab84cf91 100644 --- a/src/PhpParser/Comparing/NodeComparator.php +++ b/src/PhpParser/Comparing/NodeComparator.php @@ -28,41 +28,17 @@ public function printWithoutComments(Node|array|null $node): string return trim($content); } - /** - * @param Node|Node[]|null $firstNode - * @param Node|Node[]|null $secondNode - */ - public function areNodesEqual(Node|array|null $firstNode, Node|array|null $secondNode): bool + public function areNodesEqual(Node|null $firstNode, Node|null $secondNode): bool { - if ($firstNode === null || $secondNode === null) { + if (! $firstNode instanceof Node || ! $secondNode instanceof Node) { return false; } - if ($firstNode instanceof Node && ! $secondNode instanceof Node) { + if ($firstNode::class !== $secondNode::class) { return false; } - if (! $firstNode instanceof Node && $secondNode instanceof Node) { - return false; - } - - if (is_array($firstNode) && ! is_array($secondNode)) { - return false; - } - - if (! is_array($secondNode)) { - if ($firstNode::class !== $secondNode::class) { - return false; - } - - return $this->printWithoutComments($firstNode) === $this->printWithoutComments($secondNode); - } - - if (is_array($firstNode)) { - return $this->printWithoutComments($firstNode) === $this->printWithoutComments($secondNode); - } - - return false; + return $this->printWithoutComments($firstNode) === $this->printWithoutComments($secondNode); } /**