@@ -537,6 +537,33 @@ int zend_optimizer_replace_by_const(zend_op_array *op_array,
537
537
return 1 ;
538
538
}
539
539
540
+ static zend_class_entry * get_class_entry_from_op1 (
541
+ zend_script * script , zend_op_array * op_array , zend_op * opline , zend_bool rt_constants ) {
542
+ if (opline -> op1_type == IS_CONST ) {
543
+ zval * op1 = CRT_CONSTANT_EX (op_array , opline -> op1 , rt_constants );
544
+ if (Z_TYPE_P (op1 ) == IS_STRING ) {
545
+ zend_string * class_name = Z_STR_P (op1 + 1 );
546
+ zend_class_entry * ce ;
547
+ if (script && (ce = zend_hash_find_ptr (& script -> class_table , class_name ))) {
548
+ return ce ;
549
+ } else if ((ce = zend_hash_find_ptr (EG (class_table ), class_name ))) {
550
+ if (ce -> type == ZEND_INTERNAL_CLASS ) {
551
+ return ce ;
552
+ } else if (ce -> type == ZEND_USER_CLASS &&
553
+ ce -> info .user .filename &&
554
+ ce -> info .user .filename == op_array -> filename ) {
555
+ return ce ;
556
+ }
557
+ }
558
+ }
559
+ } else if (opline -> op1_type == IS_UNUSED && op_array -> scope
560
+ && !(op_array -> scope -> ce_flags & ZEND_ACC_TRAIT )
561
+ && (opline -> op1 .num & ZEND_FETCH_CLASS_MASK ) == ZEND_FETCH_CLASS_SELF ) {
562
+ return op_array -> scope ;
563
+ }
564
+ return NULL ;
565
+ }
566
+
540
567
zend_function * zend_optimizer_get_called_func (
541
568
zend_script * script , zend_op_array * op_array , zend_op * opline , zend_bool rt_constants )
542
569
{
@@ -579,25 +606,8 @@ zend_function *zend_optimizer_get_called_func(
579
606
break ;
580
607
case ZEND_INIT_STATIC_METHOD_CALL :
581
608
if (opline -> op2_type == IS_CONST && Z_TYPE_P (GET_OP (op2 )) == IS_STRING ) {
582
- zend_class_entry * ce = NULL ;
583
- if (opline -> op1_type == IS_CONST && Z_TYPE_P (GET_OP (op1 )) == IS_STRING ) {
584
- zend_string * class_name = Z_STR_P (GET_OP (op1 ) + 1 );
585
- if (script && (ce = zend_hash_find_ptr (& script -> class_table , class_name ))) {
586
- /* pass */
587
- } else if ((ce = zend_hash_find_ptr (EG (class_table ), class_name ))) {
588
- if (ce -> type == ZEND_INTERNAL_CLASS ) {
589
- /* pass */
590
- } else if (ce -> type != ZEND_USER_CLASS ||
591
- !ce -> info .user .filename ||
592
- ce -> info .user .filename != op_array -> filename ) {
593
- ce = NULL ;
594
- }
595
- }
596
- } else if (opline -> op1_type == IS_UNUSED && op_array -> scope
597
- && !(op_array -> scope -> ce_flags & ZEND_ACC_TRAIT )
598
- && (opline -> op1 .num & ZEND_FETCH_CLASS_MASK ) == ZEND_FETCH_CLASS_SELF ) {
599
- ce = op_array -> scope ;
600
- }
609
+ zend_class_entry * ce = get_class_entry_from_op1 (
610
+ script , op_array , opline , rt_constants );
601
611
if (ce ) {
602
612
zend_string * func_name = Z_STR_P (GET_OP (op2 ) + 1 );
603
613
return zend_hash_find_ptr (& ce -> function_table , func_name );
@@ -622,6 +632,15 @@ zend_function *zend_optimizer_get_called_func(
622
632
}
623
633
}
624
634
break ;
635
+ case ZEND_NEW :
636
+ {
637
+ zend_class_entry * ce = get_class_entry_from_op1 (
638
+ script , op_array , opline , rt_constants );
639
+ if (ce && ce -> type == ZEND_USER_CLASS ) {
640
+ return ce -> constructor ;
641
+ }
642
+ break ;
643
+ }
625
644
}
626
645
return NULL ;
627
646
#undef GET_OP
0 commit comments