diff --git a/src/PhpParser/Node/BetterNodeFinder.php b/src/PhpParser/Node/BetterNodeFinder.php index f5a42cc386d..0d373d53ca9 100644 --- a/src/PhpParser/Node/BetterNodeFinder.php +++ b/src/PhpParser/Node/BetterNodeFinder.php @@ -89,10 +89,8 @@ public function findParentType(Node $node, string $type): ?Node return $parent; } - if (! $parent instanceof Node) { - return null; - } - } while ($parent = $parent->getAttribute(AttributeKey::PARENT_NODE)); + $parent = $parent->getAttribute(AttributeKey::PARENT_NODE); + } while ($parent instanceof Node); return null; }