@@ -64,7 +64,7 @@ final class NamespacesAnalyzer
$index = $scopeEndIndex;
}
- if (0 === \count($namespaces)) {
+ if (0 === \count($namespaces) && $tokens->isTokenKindFound(T_OPEN_TAG)) {
$namespaces[] = new NamespaceAnalysis('', '', 0, 0, 0, \count($tokens) - 1);
@@ -86,6 +86,12 @@ final class NamespacesAnalyzerTest extends TestCase
17
),
]];
+
+ yield [
+ 'there is no namespace if there is no PHP code',
+ [
+ ],
+ ];
/**
@@ -155,19 +161,6 @@ final class NamespacesAnalyzerTest extends TestCase
];
-
- yield [
- ' ',
- 0,
- new NamespaceAnalysis(
- '',
- 0
- ),
- ];
public function testInvalidIndex(): void