@@ -3283,15 +3283,7 @@ public function getRegistration(array $allConstInfos): string
3283
3283
$code .= "{\n";
3284
3284
3285
3285
$flagCodes = generateVersionDependentFlagCode("%s", $this->getFlagsByPhpVersion(), $this->phpVersionIdMinimumCompatibility);
3286
- if (count($flagCodes) > 1) {
3287
- // If we have more than one entry, there will be preprocessor conditions,
3288
- // thus we need to start with a newline.
3289
- $flags = "\n" . implode("\n", $flagCodes);
3290
- } else if (count($flagCodes) === 1) {
3291
- $flags = " " . $flagCodes[0];
3292
- } else {
3293
- $flags = "";
3294
- }
3286
+ $flags = implode("", $flagCodes);
3295
3287
3296
3288
$classMethods = ($this->funcInfos === []) ? 'NULL' : "class_{$escapedName}_methods";
3297
3289
if ($this->type === "enum") {
@@ -3300,7 +3292,7 @@ public function getRegistration(array $allConstInfos): string
3300
3292
? $this->enumBackingType->toTypeCode() : "IS_UNDEF";
3301
3293
$code .= "\tzend_class_entry *class_entry = zend_register_internal_enum(\"$name\", $backingType, $classMethods);\n";
3302
3294
if ($flags !== "") {
3303
- $code .= "\tclass_entry->ce_flags |=$flags\n";
3295
+ $code .= "\tclass_entry->ce_flags |= $flags\n";
3304
3296
}
3305
3297
} else {
3306
3298
$code .= "\tzend_class_entry ce, *class_entry;\n\n";
@@ -3318,21 +3310,21 @@ public function getRegistration(array $allConstInfos): string
3318
3310
$code .= "#if (PHP_VERSION_ID >= " . PHP_84_VERSION_ID . ")\n";
3319
3311
}
3320
3312
3321
- $code .= "\tclass_entry = zend_register_internal_class_with_flags(&ce, " . (isset($this->extends[0]) ? "class_entry_" . str_replace("\\", "_", $this->extends[0]->toString()) : "NULL") . "," . ($flags ?: " 0" ) . ");\n";
3313
+ $code .= "\tclass_entry = zend_register_internal_class_with_flags(&ce, " . (isset($this->extends[0]) ? "class_entry_" . str_replace("\\", "_", $this->extends[0]->toString()) : "NULL") . ", " . ($flags ?: 0 ) . ");\n";
3322
3314
3323
3315
if (!$php84MinimumCompatibility) {
3324
3316
$code .= "#else\n";
3325
3317
3326
3318
$code .= "\tclass_entry = zend_register_internal_class_ex(&ce, " . (isset($this->extends[0]) ? "class_entry_" . str_replace("\\", "_", $this->extends[0]->toString()) : "NULL") . ");\n";
3327
3319
if ($flags !== "") {
3328
- $code .= "\tclass_entry->ce_flags |=$flags;\n";
3320
+ $code .= "\tclass_entry->ce_flags |= $flags;\n";
3329
3321
}
3330
3322
$code .= "#endif\n";
3331
3323
}
3332
3324
} else {
3333
3325
$code .= "\tclass_entry = zend_register_internal_interface(&ce);\n";
3334
3326
if ($flags !== "") {
3335
- $code .= "\tclass_entry->ce_flags |=$flags\n";
3327
+ $code .= "\tclass_entry->ce_flags |= $flags\n";
3336
3328
}
3337
3329
}
3338
3330
}
@@ -5399,16 +5391,12 @@ static function (array $value): bool {
5399
5391
$code = "";
5400
5392
5401
5393
$if = $i === 0 ? "#if" : "#elif";
5394
+ $endif = $i === $flagCount - 1 ? "#endif\n" : "";
5402
5395
5403
5396
$code .= "$if (PHP_VERSION_ID >= $version)\n";
5404
5397
5405
5398
$code .= sprintf($codeTemplate, implode("|", $versionFlags));
5406
- if ($i === $flagCount - 1) {
5407
- if (!str_ends_with($code, "\n")) {
5408
- $code .= "\n";
5409
- }
5410
- $code .= "#endif\n";
5411
- }
5399
+ $code .= $endif;
5412
5400
5413
5401
$result[] = $code;
5414
5402
$i++;
0 commit comments