@@ -3481,17 +3481,13 @@ public function getRegistration(array $allConstInfos): string
3481
3481
3482
3482
$ code .= "{ \n" ;
3483
3483
3484
- $ flags = generateVersionDependentFlagCode ("%s " , $ this ->getFlagsByPhpVersion (), $ this ->phpVersionIdMinimumCompatibility );
3485
-
3486
3484
$ classMethods = ($ this ->funcInfos === []) ? 'NULL ' : "class_ {$ escapedName }_methods " ;
3487
3485
if ($ this ->type === "enum " ) {
3488
3486
$ name = addslashes ((string ) $ this ->name );
3489
3487
$ backingType = $ this ->enumBackingType
3490
3488
? $ this ->enumBackingType ->toTypeCode () : "IS_UNDEF " ;
3491
3489
$ code .= "\tzend_class_entry *class_entry = zend_register_internal_enum( \"$ name \", $ backingType, $ classMethods); \n" ;
3492
- if ($ flags !== "" ) {
3493
- $ code .= "\tclass_entry->ce_flags |= $ flags \n" ;
3494
- }
3490
+ $ code .= generateVersionDependentFlagCode ("\tclass_entry->ce_flags = %s; \n" , $ this ->getFlagsByPhpVersion (), $ this ->phpVersionIdMinimumCompatibility );
3495
3491
} else {
3496
3492
$ code .= "\tzend_class_entry ce, *class_entry; \n\n" ;
3497
3493
if (count ($ this ->name ->getParts ()) > 1 ) {
@@ -3508,22 +3504,25 @@ public function getRegistration(array $allConstInfos): string
3508
3504
$ code .= "#if (PHP_VERSION_ID >= " . PHP_84_VERSION_ID . ") \n" ;
3509
3505
}
3510
3506
3511
- $ 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" ;
3507
+ $ 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" ;
3508
+ $ entries = generateVersionDependentFlagCode ($ template , $ this ->getFlagsByPhpVersion (), $ this ->phpVersionIdMinimumCompatibility ? max ($ this ->phpVersionIdMinimumCompatibility , PHP_84_VERSION_ID ) : null );
3509
+ if ($ entries !== '' ) {
3510
+ $ code .= $ entries ;
3511
+ } else {
3512
+ $ code .= sprintf ($ template , "0 " );
3513
+ }
3512
3514
3513
3515
if (!$ php84MinimumCompatibility ) {
3514
3516
$ code .= "#else \n" ;
3515
3517
3516
3518
$ code .= "\tclass_entry = zend_register_internal_class_ex(&ce, " . (isset ($ this ->extends [0 ]) ? "class_entry_ " . str_replace ("\\" , "_ " , $ this ->extends [0 ]->toString ()) : "NULL " ) . "); \n" ;
3517
- if ($ flags !== "" ) {
3518
- $ code .= "\tclass_entry->ce_flags |= $ flags; \n" ;
3519
- }
3519
+ $ code .= generateVersionDependentFlagCode ("\tclass_entry->ce_flags |= %s; \n" , $ this ->getFlagsByPhpVersion (), $ this ->phpVersionIdMinimumCompatibility );
3520
3520
$ code .= "#endif \n" ;
3521
3521
}
3522
3522
} else {
3523
3523
$ code .= "\tclass_entry = zend_register_internal_interface(&ce); \n" ;
3524
- if ($ flags !== "" ) {
3525
- $ code .= "\tclass_entry->ce_flags |= $ flags \n" ;
3526
- }
3524
+ $ code .= generateVersionDependentFlagCode ("\tclass_entry->ce_flags |= %s; \n" , $ this ->getFlagsByPhpVersion (), $ this ->phpVersionIdMinimumCompatibility );
3525
+
3527
3526
}
3528
3527
}
3529
3528
0 commit comments