mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
gen_stub: simplify ClassInfo::getRegistration()
This commit is contained in:
parent
74f7ecbe04
commit
747ecce51f
1 changed files with 16 additions and 30 deletions
|
@ -3594,11 +3594,17 @@ class ClassInfo {
|
|||
foreach ($this->propertyInfos as $property) {
|
||||
$code .= $property->getDeclaration($allConstInfos);
|
||||
}
|
||||
// Reusable strings for wrapping conditional PHP 8.0+ code
|
||||
if ($php80MinimumCompatibility) {
|
||||
$php80CondStart = '';
|
||||
$php80CondEnd = '';
|
||||
} else {
|
||||
$php80CondStart = "\n#if (PHP_VERSION_ID >= " . PHP_80_VERSION_ID . ")";
|
||||
$php80CondEnd = "#endif\n";
|
||||
}
|
||||
|
||||
if (!empty($this->attributes)) {
|
||||
if (!$php80MinimumCompatibility) {
|
||||
$code .= "\n#if (PHP_VERSION_ID >= " . PHP_80_VERSION_ID . ")";
|
||||
}
|
||||
$code .= $php80CondStart;
|
||||
|
||||
foreach ($this->attributes as $key => $attribute) {
|
||||
$code .= $attribute->generateCode(
|
||||
|
@ -3609,45 +3615,25 @@ class ClassInfo {
|
|||
);
|
||||
}
|
||||
|
||||
if (!$php80MinimumCompatibility) {
|
||||
$code .= "#endif\n";
|
||||
}
|
||||
$code .= $php80CondEnd;
|
||||
}
|
||||
|
||||
if ($attributeInitializationCode = generateConstantAttributeInitialization($this->constInfos, $allConstInfos, $this->phpVersionIdMinimumCompatibility, $this->cond)) {
|
||||
if (!$php80MinimumCompatibility) {
|
||||
$code .= "#if (PHP_VERSION_ID >= " . PHP_80_VERSION_ID . ")";
|
||||
}
|
||||
|
||||
$code .= $php80CondStart;
|
||||
$code .= "\n" . $attributeInitializationCode;
|
||||
|
||||
if (!$php80MinimumCompatibility) {
|
||||
$code .= "#endif\n";
|
||||
}
|
||||
$code .= $php80CondEnd;
|
||||
}
|
||||
|
||||
if ($attributeInitializationCode = generatePropertyAttributeInitialization($this->propertyInfos, $allConstInfos, $this->phpVersionIdMinimumCompatibility)) {
|
||||
if (!$php80MinimumCompatibility) {
|
||||
$code .= "#if (PHP_VERSION_ID >= " . PHP_80_VERSION_ID . ")";
|
||||
}
|
||||
|
||||
$code .= $php80CondStart;
|
||||
$code .= "\n" . $attributeInitializationCode;
|
||||
|
||||
if (!$php80MinimumCompatibility) {
|
||||
$code .= "#endif\n";
|
||||
}
|
||||
$code .= $php80CondEnd;
|
||||
}
|
||||
|
||||
if ($attributeInitializationCode = generateFunctionAttributeInitialization($this->funcInfos, $allConstInfos, $this->phpVersionIdMinimumCompatibility, $this->cond)) {
|
||||
if (!$php80MinimumCompatibility) {
|
||||
$code .= "#if (PHP_VERSION_ID >= " . PHP_80_VERSION_ID . ")\n";
|
||||
}
|
||||
|
||||
$code .= $php80CondStart;
|
||||
$code .= "\n" . $attributeInitializationCode;
|
||||
|
||||
if (!$php80MinimumCompatibility) {
|
||||
$code .= "#endif\n";
|
||||
}
|
||||
$code .= $php80CondEnd;
|
||||
}
|
||||
|
||||
$code .= "\n\treturn class_entry;\n";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue