Skip to content

Commit 67bfcae

Browse files
gen_stub: simplify FuncInfo::getFramelessDeclaration()
1 parent 7ec8fc7 commit 67bfcae

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

build/gen_stub.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,27 +1481,21 @@ public function getFramelessDeclaration(): ?string {
14811481
return null;
14821482
}
14831483

1484-
$php84MinimumCompatibility = $this->minimumPhpVersionIdCompatibility === null || $this->minimumPhpVersionIdCompatibility >= PHP_84_VERSION_ID;
1485-
14861484
$code = '';
1487-
1488-
if (!$php84MinimumCompatibility) {
1489-
$code .= "#if (PHP_VERSION_ID >= " . PHP_84_VERSION_ID . ")\n";
1490-
}
1491-
1485+
$infos = '';
14921486
foreach ($this->framelessFunctionInfos as $framelessFunctionInfo) {
14931487
$code .= "ZEND_FRAMELESS_FUNCTION({$this->name->getFunctionName()}, {$framelessFunctionInfo->arity});\n";
1488+
$infos .= "\t{ ZEND_FRAMELESS_FUNCTION_NAME({$this->name->getFunctionName()}, {$framelessFunctionInfo->arity}), {$framelessFunctionInfo->arity} },\n";
14941489
}
14951490

14961491
$code .= 'static const zend_frameless_function_info ' . $this->getFramelessFunctionInfosName() . "[] = {\n";
1497-
foreach ($this->framelessFunctionInfos as $framelessFunctionInfo) {
1498-
$code .= "\t{ ZEND_FRAMELESS_FUNCTION_NAME({$this->name->getFunctionName()}, {$framelessFunctionInfo->arity}), {$framelessFunctionInfo->arity} },\n";
1499-
}
1492+
$code .= $infos;
15001493
$code .= "\t{ 0 },\n";
15011494
$code .= "};\n";
15021495

1496+
$php84MinimumCompatibility = $this->minimumPhpVersionIdCompatibility === null || $this->minimumPhpVersionIdCompatibility >= PHP_84_VERSION_ID;
15031497
if (!$php84MinimumCompatibility) {
1504-
$code .= "#endif\n";
1498+
return "#if (PHP_VERSION_ID >= " . PHP_84_VERSION_ID . ")\n$code#endif\n";
15051499
}
15061500

15071501
return $code;

0 commit comments

Comments
 (0)