gen_stub: simplify generateFunctionEntries()

This commit is contained in:
Daniel Scherzer 2025-05-14 12:57:24 -04:00
parent 30c8480a39
commit 15547a2eb1

View file

@ -5321,19 +5321,13 @@ function generateFunctionEntries(?Name $className, array $funcInfos, ?string $co
return ''; return '';
} }
$code = "\n";
if ($cond) {
$code .= "#if {$cond}\n";
}
$functionEntryName = "ext_functions"; $functionEntryName = "ext_functions";
if ($className) { if ($className) {
$underscoreName = implode("_", $className->getParts()); $underscoreName = implode("_", $className->getParts());
$functionEntryName = "class_{$underscoreName}_methods"; $functionEntryName = "class_{$underscoreName}_methods";
} }
$code .= "static const zend_function_entry {$functionEntryName}[] = {\n"; $code = "\nstatic const zend_function_entry {$functionEntryName}[] = {\n";
$code .= generateCodeWithConditions($funcInfos, "", static function (FuncInfo $funcInfo) { $code .= generateCodeWithConditions($funcInfos, "", static function (FuncInfo $funcInfo) {
return $funcInfo->getFunctionEntry(); return $funcInfo->getFunctionEntry();
}, $cond); }, $cond);
@ -5341,7 +5335,7 @@ function generateFunctionEntries(?Name $className, array $funcInfos, ?string $co
$code .= "};\n"; $code .= "};\n";
if ($cond) { if ($cond) {
$code .= "#endif\n"; $code = "\n#if {$cond}{$code}#endif\n";
} }
return $code; return $code;