Skip to content

Commit 7428e65

Browse files
gen_stub: simplify FuncInfo::getFramelessDeclaration()
1 parent 1ccb58a commit 7428e65

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
@@ -1484,27 +1484,21 @@ public function getFramelessDeclaration(): ?string {
14841484
return null;
14851485
}
14861486

1487-
$php84MinimumCompatibility = $this->minimumPhpVersionIdCompatibility === null || $this->minimumPhpVersionIdCompatibility >= PHP_84_VERSION_ID;
1488-
14891487
$code = '';
1490-
1491-
if (!$php84MinimumCompatibility) {
1492-
$code .= "#if (PHP_VERSION_ID >= " . PHP_84_VERSION_ID . ")\n";
1493-
}
1494-
1488+
$infos = '';
14951489
foreach ($this->framelessFunctionInfos as $framelessFunctionInfo) {
14961490
$code .= "ZEND_FRAMELESS_FUNCTION({$this->name->getFunctionName()}, {$framelessFunctionInfo->arity});\n";
1491+
$infos .= "\t{ ZEND_FRAMELESS_FUNCTION_NAME({$this->name->getFunctionName()}, {$framelessFunctionInfo->arity}), {$framelessFunctionInfo->arity} },\n";
14971492
}
14981493

14991494
$code .= 'static const zend_frameless_function_info ' . $this->getFramelessFunctionInfosName() . "[] = {\n";
1500-
foreach ($this->framelessFunctionInfos as $framelessFunctionInfo) {
1501-
$code .= "\t{ ZEND_FRAMELESS_FUNCTION_NAME({$this->name->getFunctionName()}, {$framelessFunctionInfo->arity}), {$framelessFunctionInfo->arity} },\n";
1502-
}
1495+
$code .= $infos;
15031496
$code .= "\t{ 0 },\n";
15041497
$code .= "};\n";
15051498

1499+
$php84MinimumCompatibility = $this->minimumPhpVersionIdCompatibility === null || $this->minimumPhpVersionIdCompatibility >= PHP_84_VERSION_ID;
15061500
if (!$php84MinimumCompatibility) {
1507-
$code .= "#endif\n";
1501+
return "#if (PHP_VERSION_ID >= " . PHP_84_VERSION_ID . ")\n$code#endif\n";
15081502
}
15091503

15101504
return $code;

0 commit comments

Comments
 (0)