diff --git a/src/Node.php b/src/Node.php index 2eb6ebdc..d1288876 100644 --- a/src/Node.php +++ b/src/Node.php @@ -584,7 +584,7 @@ public function getImportTablesForCurrentScope() { * @return NamespaceDefinition|null */ public function getNamespaceDefinition() { - $namespaceDefinition = $this instanceof NamespaceDefinition + $namespaceDefinition = ($this instanceof NamespaceDefinition || $this instanceof SourceFileNode) ? $this : $this->getFirstAncestor(NamespaceDefinition::class, SourceFileNode::class);