Skip to content

Commit 39a6d60

Browse files
gen_stub: move funcInfoToCode() into FuncInfo
Reduce the number of global functions by moving it to instance method `FuncInfo::toArgInfoCode()`. In the process, make `FuncInfo::$numRequiredArgs` private.
1 parent b5361d7 commit 39a6d60

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

build/gen_stub.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,7 @@ class FuncInfo {
12701270
/** @var ArgInfo[] */
12711271
public /* readonly */ array $args;
12721272
public /* readonly */ ReturnInfo $return;
1273-
public /* readonly */ int $numRequiredArgs;
1273+
private /* readonly */ int $numRequiredArgs;
12741274
public /* readonly */ ?string $cond;
12751275
public bool $isUndocumentable;
12761276
private ?int $minimumPhpVersionIdCompatibility;
@@ -2228,6 +2228,21 @@ public function findEquivalent(array $generatedFuncInfos): ?FuncInfo {
22282228
return null;
22292229
}
22302230

2231+
public function toArgInfoCode(?int $minPHPCompatability): string {
2232+
$code = $this->return->beginArgInfo(
2233+
$this->getArgInfoName(),
2234+
$this->numRequiredArgs,
2235+
$minPHPCompatability === null || $minPHPCompatability >= PHP_81_VERSION_ID
2236+
);
2237+
2238+
foreach ($this->args as $argInfo) {
2239+
$code .= $argInfo->toZendInfo();
2240+
}
2241+
2242+
$code .= "ZEND_END_ARG_INFO()";
2243+
return $code . "\n";
2244+
}
2245+
22312246
public function __clone()
22322247
{
22332248
foreach ($this->args as $key => $argInfo) {
@@ -5074,21 +5089,6 @@ protected function pName_FullyQualified(Name\FullyQualified $node): string {
50745089
return $fileInfo;
50755090
}
50765091

5077-
function funcInfoToCode(FileInfo $fileInfo, FuncInfo $funcInfo): string {
5078-
$code = $funcInfo->return->beginArgInfo(
5079-
$funcInfo->getArgInfoName(),
5080-
$funcInfo->numRequiredArgs,
5081-
$fileInfo->getMinimumPhpVersionIdCompatibility() === null || $fileInfo->getMinimumPhpVersionIdCompatibility() >= PHP_81_VERSION_ID
5082-
);
5083-
5084-
foreach ($funcInfo->args as $argInfo) {
5085-
$code .= $argInfo->toZendInfo();
5086-
}
5087-
5088-
$code .= "ZEND_END_ARG_INFO()";
5089-
return $code . "\n";
5090-
}
5091-
50925092
/**
50935093
* @template T
50945094
* @param iterable<T> $infos
@@ -5168,7 +5168,7 @@ static function (FuncInfo $funcInfo) use (&$generatedFuncInfos, $fileInfo) {
51685168
$funcInfo->getArgInfoName(), $generatedFuncInfo->getArgInfoName()
51695169
);
51705170
} else {
5171-
$code = funcInfoToCode($fileInfo, $funcInfo);
5171+
$code = $funcInfo->toArgInfoCode($fileInfo->getMinimumPhpVersionIdCompatibility());
51725172
}
51735173

51745174
$generatedFuncInfos[] = $funcInfo;

0 commit comments

Comments
 (0)