@@ -3282,18 +3282,13 @@ public function getRegistration(array $allConstInfos): string
32823282
32833283 $code .= "{\n";
32843284
3285- $flagCodes = generateVersionDependentFlagCode("%s", $this->getFlagsByPhpVersion(), $this->phpVersionIdMinimumCompatibility);
3286- $flags = implode("", $flagCodes);
3287-
32883285 $classMethods = ($this->funcInfos === []) ? 'NULL' : "class_{$escapedName}_methods";
32893286 if ($this->type === "enum") {
32903287 $name = addslashes((string) $this->name);
32913288 $backingType = $this->enumBackingType
32923289 ? $this->enumBackingType->toTypeCode() : "IS_UNDEF";
32933290 $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));
32973292 } else {
32983293 $code .= "\tzend_class_entry ce, *class_entry;\n\n";
32993294 if (count($this->name->getParts()) > 1) {
@@ -3310,22 +3305,25 @@ public function getRegistration(array $allConstInfos): string
33103305 $code .= "#if (PHP_VERSION_ID >= " . PHP_84_VERSION_ID . ")\n";
33113306 }
33123307
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+ }
33143315
33153316 if (!$php84MinimumCompatibility) {
33163317 $code .= "#else\n";
33173318
33183319 $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));
33223321 $code .= "#endif\n";
33233322 }
33243323 } else {
33253324 $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+
33293327 }
33303328 }
33313329
0 commit comments