mirror of
https://github.com/php/php-src.git
synced 2026-04-04 22:52:40 +02:00
Check that all preprocessor conditions are terminated
This commit is contained in:
@@ -3657,6 +3657,8 @@ function getFileDocComment(array $stmts): ?DocComment {
|
||||
function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstract $prettyPrinter) {
|
||||
$conds = [];
|
||||
foreach ($stmts as $stmt) {
|
||||
$cond = handlePreprocessorConditions($conds, $stmt);
|
||||
|
||||
if ($stmt instanceof Stmt\Nop) {
|
||||
continue;
|
||||
}
|
||||
@@ -3666,8 +3668,6 @@ function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstrac
|
||||
continue;
|
||||
}
|
||||
|
||||
$cond = handlePreprocessorConditions($conds, $stmt);
|
||||
|
||||
if ($stmt instanceof Stmt\Const_) {
|
||||
foreach ($stmt->consts as $const) {
|
||||
$fileInfo->constInfos[] = parseConstLike(
|
||||
@@ -3775,6 +3775,9 @@ function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstrac
|
||||
|
||||
throw new Exception("Unexpected node {$stmt->getType()}");
|
||||
}
|
||||
if (!empty($conds)) {
|
||||
throw new Exception("Unterminated preprocessor conditions");
|
||||
}
|
||||
}
|
||||
|
||||
function parseStubFile(string $code): FileInfo {
|
||||
|
||||
Reference in New Issue
Block a user