Skip to content

Commit 3816597

Browse files
committed
Put built-in PHP enums in classes map
1 parent 8f3f332 commit 3816597

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

extractor/extract.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -267,20 +267,22 @@ public function clear(): void
267267
$pathPart = 'stubs/' . dirname($relativeStubPath) . '/' . str_replace('\\', '/', $namespacedName) . '.php';
268268
$targetStubPath = __DIR__ . '/../' . $pathPart;
269269

270-
if ($stmt instanceof Node\Stmt\Class_ || $stmt instanceof Node\Stmt\Interface_ || $stmt instanceof Node\Stmt\Trait_) {
270+
if ($stmt instanceof Node\Stmt\Class_ || $stmt instanceof Node\Stmt\Interface_ || $stmt instanceof Node\Stmt\Trait_ || $stmt instanceof Node\Stmt\Enum_) {
271271
if (array_key_exists(strtolower($namespacedName), $classes)) {
272272
continue;
273273
}
274274
$classes[strtolower($namespacedName)] = $pathPart;
275275
$stmt = $this->filterClassPhpDocs($stmt);
276-
} else {
276+
} elseif ($stmt instanceof Node\Stmt\Function_) {
277277
if (in_array($namespacedName, ['_exit', '_die'], true)) {
278278
continue;
279279
}
280280
if (array_key_exists(strtolower($namespacedName), $functions)) {
281281
continue;
282282
}
283283
$functions[strtolower($namespacedName)] = $pathPart;
284+
} else {
285+
throw new \Exception(sprintf('Unhandled node type %s in %s on line %s.', get_class($stmt), $stubPath, $stmt->getLine()));
284286
}
285287

286288
$originalStmt = $stmt;

0 commit comments

Comments
 (0)