@@ -464,74 +464,7 @@ static int zend_ast_add_unpacked_element(zval *result, zval *expr) {
464
464
}
465
465
}
466
466
} ZEND_HASH_FOREACH_END ();
467
- } else if (EXPECTED (Z_TYPE_P (expr ) == IS_OBJECT )) {
468
- zend_class_entry * ce = Z_OBJCE_P (expr );
469
- zend_object_iterator * iter ;
470
-
471
- if (!ce || !ce -> get_iterator ) {
472
- zend_throw_error (NULL , "Only arrays and Traversables can be unpacked" );
473
- return FAILURE ;
474
- } else {
475
- iter = ce -> get_iterator (ce , expr , 0 );
476
- if (UNEXPECTED (!iter )) {
477
- if (!EG (exception )) {
478
- zend_throw_exception_ex (
479
- NULL , 0 , "Object of type %s did not create an Iterator" , ZSTR_VAL (ce -> name )
480
- );
481
- }
482
- return FAILURE ;
483
- }
484
-
485
- if (iter -> funcs -> rewind ) {
486
- iter -> funcs -> rewind (iter );
487
- }
488
-
489
- for (; iter -> funcs -> valid (iter ) == SUCCESS ; ) {
490
- zval * val ;
491
-
492
- if (UNEXPECTED (EG (exception ) != NULL )) {
493
- break ;
494
- }
495
-
496
- val = iter -> funcs -> get_current_data (iter );
497
- if (UNEXPECTED (EG (exception ) != NULL )) {
498
- break ;
499
- }
500
-
501
- if (iter -> funcs -> get_current_key ) {
502
- zval key ;
503
- iter -> funcs -> get_current_key (iter , & key );
504
- if (UNEXPECTED (EG (exception ) != NULL )) {
505
- break ;
506
- }
507
-
508
- if (UNEXPECTED (Z_TYPE (key ) != IS_LONG )) {
509
- zend_throw_error (NULL ,
510
- (Z_TYPE (key ) == IS_STRING ) ?
511
- "Cannot unpack Traversable with string keys" :
512
- "Cannot unpack Traversable with non-integer keys" );
513
- zval_ptr_dtor (& key );
514
- break ;
515
- }
516
- }
517
-
518
- ZVAL_DEREF (val );
519
- Z_TRY_ADDREF_P (val );
520
-
521
- if (!zend_hash_next_index_insert (Z_ARRVAL_P (result ), val )) {
522
- zend_error (E_WARNING , "Cannot add element to the array as the next element is already occupied" );
523
- zval_ptr_dtor_nogc (val );
524
- }
525
-
526
- iter -> funcs -> move_forward (iter );
527
- }
528
-
529
- zend_iterator_dtor (iter );
530
- }
531
- } else if (EXPECTED (Z_ISREF_P (expr ))) {
532
- expr = Z_REFVAL_P (expr );
533
- return zend_ast_add_unpacked_element (result , expr );
534
- } else {
467
+ } else { //objects or refernces cannot occur in a constant expression
535
468
zend_throw_error (NULL , "Only arrays and Traversables can be unpacked" );
536
469
return FAILURE ;
537
470
}
0 commit comments