mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
gen_stub: convert ArgInfo::$sendBy
to a string
Instead of using integers that then need to be converted to the string representation via `::getSendByString()`, just always store a string, eliminating the conversion method and replacing it with property access.
This commit is contained in:
parent
9ab74588d5
commit
dd72c4325c
1 changed files with 10 additions and 22 deletions
|
@ -774,12 +774,12 @@ class ArginfoType {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArgInfo {
|
class ArgInfo {
|
||||||
const SEND_BY_VAL = 0;
|
const SEND_BY_VAL = "0";
|
||||||
const SEND_BY_REF = 1;
|
const SEND_BY_REF = "1";
|
||||||
const SEND_PREFER_REF = 2;
|
const SEND_PREFER_REF = "ZEND_SEND_PREFER_REF";
|
||||||
|
|
||||||
public string $name;
|
public string $name;
|
||||||
public int $sendBy;
|
public string $sendBy;
|
||||||
public bool $isVariadic;
|
public bool $isVariadic;
|
||||||
public ?Type $type;
|
public ?Type $type;
|
||||||
public ?Type $phpDocType;
|
public ?Type $phpDocType;
|
||||||
|
@ -792,7 +792,7 @@ class ArgInfo {
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $name,
|
string $name,
|
||||||
int $sendBy,
|
string $sendBy,
|
||||||
bool $isVariadic,
|
bool $isVariadic,
|
||||||
?Type $type,
|
?Type $type,
|
||||||
?Type $phpDocType,
|
?Type $phpDocType,
|
||||||
|
@ -816,18 +816,6 @@ class ArgInfo {
|
||||||
&& $this->defaultValue === $other->defaultValue;
|
&& $this->defaultValue === $other->defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSendByString(): string {
|
|
||||||
switch ($this->sendBy) {
|
|
||||||
case self::SEND_BY_VAL:
|
|
||||||
return "0";
|
|
||||||
case self::SEND_BY_REF:
|
|
||||||
return "1";
|
|
||||||
case self::SEND_PREFER_REF:
|
|
||||||
return "ZEND_SEND_PREFER_REF";
|
|
||||||
}
|
|
||||||
throw new Exception("Invalid sendBy value");
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMethodSynopsisType(): Type {
|
public function getMethodSynopsisType(): Type {
|
||||||
if ($this->type) {
|
if ($this->type) {
|
||||||
return $this->type;
|
return $this->type;
|
||||||
|
@ -5038,14 +5026,14 @@ function funcInfoToCode(FileInfo $fileInfo, FuncInfo $funcInfo): string {
|
||||||
if ($simpleArgType->isBuiltin) {
|
if ($simpleArgType->isBuiltin) {
|
||||||
$code .= sprintf(
|
$code .= sprintf(
|
||||||
"\tZEND_%s_TYPE_INFO%s(%s, %s, %s, %d%s)\n",
|
"\tZEND_%s_TYPE_INFO%s(%s, %s, %s, %d%s)\n",
|
||||||
$argKind, $argDefaultKind, $argInfo->getSendByString(), $argInfo->name,
|
$argKind, $argDefaultKind, $argInfo->sendBy, $argInfo->name,
|
||||||
$simpleArgType->toTypeCode(), $argType->isNullable(),
|
$simpleArgType->toTypeCode(), $argType->isNullable(),
|
||||||
$argInfo->hasProperDefaultValue() ? ", " . $argInfo->getDefaultValueAsArginfoString() : ""
|
$argInfo->hasProperDefaultValue() ? ", " . $argInfo->getDefaultValueAsArginfoString() : ""
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$code .= sprintf(
|
$code .= sprintf(
|
||||||
"\tZEND_%s_OBJ_INFO%s(%s, %s, %s, %d%s)\n",
|
"\tZEND_%s_OBJ_INFO%s(%s, %s, %s, %d%s)\n",
|
||||||
$argKind,$argDefaultKind, $argInfo->getSendByString(), $argInfo->name,
|
$argKind,$argDefaultKind, $argInfo->sendBy, $argInfo->name,
|
||||||
$simpleArgType->toEscapedName(), $argType->isNullable(),
|
$simpleArgType->toEscapedName(), $argType->isNullable(),
|
||||||
$argInfo->hasProperDefaultValue() ? ", " . $argInfo->getDefaultValueAsArginfoString() : ""
|
$argInfo->hasProperDefaultValue() ? ", " . $argInfo->getDefaultValueAsArginfoString() : ""
|
||||||
);
|
);
|
||||||
|
@ -5055,14 +5043,14 @@ function funcInfoToCode(FileInfo $fileInfo, FuncInfo $funcInfo): string {
|
||||||
if ($arginfoType->hasClassType()) {
|
if ($arginfoType->hasClassType()) {
|
||||||
$code .= sprintf(
|
$code .= sprintf(
|
||||||
"\tZEND_%s_OBJ_TYPE_MASK(%s, %s, %s, %s%s)\n",
|
"\tZEND_%s_OBJ_TYPE_MASK(%s, %s, %s, %s%s)\n",
|
||||||
$argKind, $argInfo->getSendByString(), $argInfo->name,
|
$argKind, $argInfo->sendBy, $argInfo->name,
|
||||||
$arginfoType->toClassTypeString(), $arginfoType->toTypeMask(),
|
$arginfoType->toClassTypeString(), $arginfoType->toTypeMask(),
|
||||||
!$argInfo->isVariadic ? ", " . $argInfo->getDefaultValueAsArginfoString() : ""
|
!$argInfo->isVariadic ? ", " . $argInfo->getDefaultValueAsArginfoString() : ""
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$code .= sprintf(
|
$code .= sprintf(
|
||||||
"\tZEND_%s_TYPE_MASK(%s, %s, %s, %s)\n",
|
"\tZEND_%s_TYPE_MASK(%s, %s, %s, %s)\n",
|
||||||
$argKind, $argInfo->getSendByString(), $argInfo->name,
|
$argKind, $argInfo->sendBy, $argInfo->name,
|
||||||
$arginfoType->toTypeMask(),
|
$arginfoType->toTypeMask(),
|
||||||
$argInfo->getDefaultValueAsArginfoString()
|
$argInfo->getDefaultValueAsArginfoString()
|
||||||
);
|
);
|
||||||
|
@ -5071,7 +5059,7 @@ function funcInfoToCode(FileInfo $fileInfo, FuncInfo $funcInfo): string {
|
||||||
} else {
|
} else {
|
||||||
$code .= sprintf(
|
$code .= sprintf(
|
||||||
"\tZEND_%s_INFO%s(%s, %s%s)\n",
|
"\tZEND_%s_INFO%s(%s, %s%s)\n",
|
||||||
$argKind, $argDefaultKind, $argInfo->getSendByString(), $argInfo->name,
|
$argKind, $argDefaultKind, $argInfo->sendBy, $argInfo->name,
|
||||||
$argInfo->hasProperDefaultValue() ? ", " . $argInfo->getDefaultValueAsArginfoString() : ""
|
$argInfo->hasProperDefaultValue() ? ", " . $argInfo->getDefaultValueAsArginfoString() : ""
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue