@@ -315,7 +315,9 @@ void zend_enum_register_funcs(zend_class_entry *ce)
315
315
cases_function -> scope = ce ;
316
316
cases_function -> fn_flags = fn_flags ;
317
317
cases_function -> arg_info = (zend_internal_arg_info * ) (arginfo_class_UnitEnum_cases + 1 );
318
- zend_hash_add_ptr (& ce -> function_table , ZSTR_KNOWN (ZEND_STR_CASES ), cases_function );
318
+ if (!zend_hash_add_ptr (& ce -> function_table , ZSTR_KNOWN (ZEND_STR_CASES ), cases_function )) {
319
+ zend_error_noreturn (E_COMPILE_ERROR , "Cannot redeclare %s::cases()" , ZSTR_VAL (ce -> name ));
320
+ }
319
321
320
322
if (ce -> enum_backing_type != IS_UNDEF ) {
321
323
zend_internal_function * from_function =
@@ -330,7 +332,10 @@ void zend_enum_register_funcs(zend_class_entry *ce)
330
332
from_function -> num_args = 1 ;
331
333
from_function -> required_num_args = 1 ;
332
334
from_function -> arg_info = (zend_internal_arg_info * ) (arginfo_class_BackedEnum_from + 1 );
333
- zend_hash_add_ptr (& ce -> function_table , ZSTR_KNOWN (ZEND_STR_FROM ), from_function );
335
+ if (!zend_hash_add_ptr (& ce -> function_table , ZSTR_KNOWN (ZEND_STR_FROM ), from_function )) {
336
+ zend_error_noreturn (E_COMPILE_ERROR ,
337
+ "Cannot redeclare %s::from()" , ZSTR_VAL (ce -> name ));
338
+ }
334
339
335
340
zend_internal_function * try_from_function =
336
341
zend_arena_alloc (& CG (arena ), sizeof (zend_internal_function ));
@@ -344,8 +349,11 @@ void zend_enum_register_funcs(zend_class_entry *ce)
344
349
try_from_function -> num_args = 1 ;
345
350
try_from_function -> required_num_args = 1 ;
346
351
try_from_function -> arg_info = (zend_internal_arg_info * ) (arginfo_class_BackedEnum_tryFrom + 1 );
347
- zend_hash_add_ptr (
348
- & ce -> function_table , ZSTR_KNOWN (ZEND_STR_TRYFROM_LOWERCASE ), try_from_function );
352
+ if (!zend_hash_add_ptr (
353
+ & ce -> function_table , ZSTR_KNOWN (ZEND_STR_TRYFROM_LOWERCASE ), try_from_function )) {
354
+ zend_error_noreturn (E_COMPILE_ERROR ,
355
+ "Cannot redeclare %s::tryFrom()" , ZSTR_VAL (ce -> name ));
356
+ }
349
357
}
350
358
}
351
359
0 commit comments