@@ -3282,18 +3282,13 @@ public function getRegistration(array $allConstInfos): string
3282
3282
3283
3283
$code .= "{\n";
3284
3284
3285
- $flagCodes = generateVersionDependentFlagCode("%s", $this->getFlagsByPhpVersion(), $this->phpVersionIdMinimumCompatibility);
3286
- $flags = implode("", $flagCodes);
3287
-
3288
3285
$classMethods = ($this->funcInfos === []) ? 'NULL' : "class_{$escapedName}_methods";
3289
3286
if ($this->type === "enum") {
3290
3287
$name = addslashes((string) $this->name);
3291
3288
$backingType = $this->enumBackingType
3292
3289
? $this->enumBackingType->toTypeCode() : "IS_UNDEF";
3293
3290
$code .= "\tzend_class_entry *class_entry = zend_register_internal_enum(\"$name\", $backingType, $classMethods);\n";
3294
- if ($flags !== "") {
3295
- $code .= "\tclass_entry->ce_flags |= $flags\n";
3296
- }
3291
+ $code .= implode("", generateVersionDependentFlagCode("\tclass_entry->ce_flags = %s;\n", $this->getFlagsByPhpVersion(), $this->phpVersionIdMinimumCompatibility));
3297
3292
} else {
3298
3293
$code .= "\tzend_class_entry ce, *class_entry;\n\n";
3299
3294
if (count($this->name->getParts()) > 1) {
@@ -3310,22 +3305,25 @@ public function getRegistration(array $allConstInfos): string
3310
3305
$code .= "#if (PHP_VERSION_ID >= " . PHP_84_VERSION_ID . ")\n";
3311
3306
}
3312
3307
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";
3308
+ $template = "\tclass_entry = zend_register_internal_class_with_flags(&ce, " . (isset($this->extends[0]) ? "class_entry_" . str_replace("\\", "_", $this->extends[0]->toString()) : "NULL") . ", %s);\n";
3309
+ $entries = generateVersionDependentFlagCode($template, $this->getFlagsByPhpVersion(), $this->phpVersionIdMinimumCompatibility ? max($this->phpVersionIdMinimumCompatibility, PHP_84_VERSION_ID) : null);
3310
+ if ($entries !== []) {
3311
+ $code .= implode("", $entries);
3312
+ } else {
3313
+ $code .= sprintf($template, "0");
3314
+ }
3314
3315
3315
3316
if (!$php84MinimumCompatibility) {
3316
3317
$code .= "#else\n";
3317
3318
3318
3319
$code .= "\tclass_entry = zend_register_internal_class_ex(&ce, " . (isset($this->extends[0]) ? "class_entry_" . str_replace("\\", "_", $this->extends[0]->toString()) : "NULL") . ");\n";
3319
- if ($flags !== "") {
3320
- $code .= "\tclass_entry->ce_flags |= $flags;\n";
3321
- }
3320
+ $code .= implode("", generateVersionDependentFlagCode("\tclass_entry->ce_flags |= %s;\n", $this->getFlagsByPhpVersion(), $this->phpVersionIdMinimumCompatibility));
3322
3321
$code .= "#endif\n";
3323
3322
}
3324
3323
} else {
3325
3324
$code .= "\tclass_entry = zend_register_internal_interface(&ce);\n";
3326
- if ($flags !== "") {
3327
- $code .= "\tclass_entry->ce_flags |= $flags\n";
3328
- }
3325
+ $code .= implode("", generateVersionDependentFlagCode("\tclass_entry->ce_flags |= %s;\n", $this->getFlagsByPhpVersion(), $this->phpVersionIdMinimumCompatibility));
3326
+
3329
3327
}
3330
3328
}
3331
3329
0 commit comments