Skip to content

Commit 36fdc6f

Browse files
committed
Check that all preprocessor conditions are terminated
1 parent 27bde17 commit 36fdc6f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

build/gen_stub.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -3657,6 +3657,8 @@ function getFileDocComment(array $stmts): ?DocComment {
36573657
function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstract $prettyPrinter) {
36583658
$conds = [];
36593659
foreach ($stmts as $stmt) {
3660+
$cond = handlePreprocessorConditions($conds, $stmt);
3661+
36603662
if ($stmt instanceof Stmt\Nop) {
36613663
continue;
36623664
}
@@ -3666,8 +3668,6 @@ function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstrac
36663668
continue;
36673669
}
36683670

3669-
$cond = handlePreprocessorConditions($conds, $stmt);
3670-
36713671
if ($stmt instanceof Stmt\Const_) {
36723672
foreach ($stmt->consts as $const) {
36733673
$fileInfo->constInfos[] = parseConstLike(
@@ -3775,6 +3775,9 @@ function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstrac
37753775

37763776
throw new Exception("Unexpected node {$stmt->getType()}");
37773777
}
3778+
if (!empty($conds)) {
3779+
throw new Exception("Unterminated preprocessor conditions");
3780+
}
37783781
}
37793782

37803783
function parseStubFile(string $code): FileInfo {

0 commit comments

Comments
 (0)