Skip to content

Commit 49f1685

Browse files
gen_stub: simplify FuncInfo::getFramelessDeclaration()
1 parent 988da4c commit 49f1685

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

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

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

1497+
$php84MinimumCompatibility = $this->minimumPhpVersionIdCompatibility === null || $this->minimumPhpVersionIdCompatibility >= PHP_84_VERSION_ID;
15041498
if (!$php84MinimumCompatibility) {
1505-
$code .= "#endif\n";
1499+
return "#if (PHP_VERSION_ID >= " . PHP_84_VERSION_ID . ")\n$code#endif\n";
15061500
}
15071501

15081502
return $code;

0 commit comments

Comments
 (0)