@@ -831,6 +831,64 @@ zend_class_entry *zend_optimizer_get_class_entry_from_op1(
831831 return NULL ;
832832}
833833
834+ const zend_class_constant * zend_fetch_class_const_info (
835+ const zend_script * script , const zend_op_array * op_array , const zend_op * opline , bool * is_prototype ) {
836+ const zend_class_entry * ce = NULL ;
837+ bool is_static_reference = false;
838+
839+ if (!opline || !op_array || opline -> op2_type != IS_CONST || Z_TYPE_P (CRT_CONSTANT (opline -> op2 )) != IS_STRING ) {
840+ return NULL ;
841+ }
842+ if (opline -> op1_type == IS_CONST ) {
843+ zval * op1 = CRT_CONSTANT (opline -> op1 );
844+ if (Z_TYPE_P (op1 ) == IS_STRING ) {
845+ if (script ) {
846+ ce = zend_optimizer_get_class_entry (script , op_array , Z_STR_P (op1 + 1 ));
847+ } else {
848+ zend_class_entry * tmp = zend_hash_find_ptr (EG (class_table ), Z_STR_P (op1 + 1 ));
849+ if (tmp != NULL ) {
850+ if (tmp -> type == ZEND_INTERNAL_CLASS ) {
851+ ce = tmp ;
852+ } else if (tmp -> type == ZEND_USER_CLASS
853+ && tmp -> info .user .filename
854+ && tmp -> info .user .filename == op_array -> filename ) {
855+ ce = tmp ;
856+ }
857+ }
858+ }
859+ }
860+ } else if (opline -> op1_type == IS_UNUSED
861+ && op_array -> scope && !(op_array -> scope -> ce_flags & ZEND_ACC_TRAIT )
862+ && !(op_array -> fn_flags & ZEND_ACC_TRAIT_CLONE )) {
863+ int fetch_type = opline -> op1 .num & ZEND_FETCH_CLASS_MASK ;
864+ if (fetch_type == ZEND_FETCH_CLASS_SELF ) {
865+ ce = op_array -> scope ;
866+ } else if (fetch_type == ZEND_FETCH_CLASS_STATIC ) {
867+ ce = op_array -> scope ;
868+ is_static_reference = true;
869+ } else if (fetch_type == ZEND_FETCH_CLASS_PARENT ) {
870+ if (op_array -> scope -> ce_flags & ZEND_ACC_LINKED ) {
871+ ce = op_array -> scope -> parent ;
872+ }
873+ }
874+ }
875+ if (!ce || (ce -> ce_flags & ZEND_ACC_TRAIT )) {
876+ return NULL ;
877+ }
878+ zend_class_constant * const_info = zend_hash_find_ptr (& ce -> constants_table , Z_STR_P (CRT_CONSTANT (opline -> op2 )));
879+ if (!const_info ) {
880+ return NULL ;
881+ }
882+ if ((ZEND_CLASS_CONST_FLAGS (const_info ) & ZEND_ACC_DEPRECATED )
883+ || ((ZEND_CLASS_CONST_FLAGS (const_info ) & ZEND_ACC_PPP_MASK ) != ZEND_ACC_PUBLIC && const_info -> ce != op_array -> scope )) {
884+ return NULL ;
885+ }
886+ * is_prototype = is_static_reference
887+ && !(const_info -> ce -> ce_flags & ZEND_ACC_FINAL ) && !(ZEND_CLASS_CONST_FLAGS (const_info ) & ZEND_ACC_FINAL );
888+
889+ return const_info ;
890+ }
891+
834892zend_function * zend_optimizer_get_called_func (
835893 zend_script * script , zend_op_array * op_array , zend_op * opline , bool * is_prototype )
836894{
0 commit comments