From: Dmitry Stogov Date: Sat, 29 Sep 2007 09:34:24 +0000 (+0000) Subject: Added support for __callstatic() magic method (missing part). (Sara) X-Git-Tag: BEFORE_IMPORT_OF_MYSQLND_IN_5_3~61 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=72d0454bf6734261679439f88b1bf8c273cbee02;p=php Added support for __callstatic() magic method (missing part). (Sara) --- diff --git a/Zend/zend.h b/Zend/zend.h index 63b2e51889..8afe53fda0 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -351,6 +351,7 @@ struct _zend_class_entry { zend_object_value (*create_object)(zend_class_entry *class_type TSRMLS_DC); zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC); int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type TSRMLS_DC); /* a class implements this interface */ + union _zend_function *(*get_static_method)(zend_class_entry *ce, char* method, int method_len TSRMLS_DC); /* serializer callbacks */ int (*serialize)(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC); diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 84d7949aed..f44b6fdf47 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -138,6 +138,7 @@ typedef struct _zend_function_entry { class_container.unserialize = NULL; \ class_container.create_object = NULL; \ class_container.interface_gets_implemented = NULL; \ + class_container.get_static_method = NULL; \ class_container.__call = handle_fcall; \ class_container.__callstatic = handle_fcall; \ class_container.__tostring = NULL; \ diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 7c4f4a87fc..ce59b4954e 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4491,6 +4491,7 @@ ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify ce->get_iterator = NULL; ce->iterator_funcs.funcs = NULL; ce->interface_gets_implemented = NULL; + ce->get_static_method = NULL; ce->parent = NULL; ce->num_interfaces = 0; ce->interfaces = NULL; diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 5157777566..993d308450 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -835,8 +835,13 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS } else if (calling_scope) { char *function_name_lc = zend_str_tolower_dup(fname, fname_len); - EX(function_state).function = - zend_std_get_static_method(calling_scope, function_name_lc, fname_len TSRMLS_CC); + if (calling_scope->get_static_method) { + EX(function_state).function = + calling_scope->get_static_method(calling_scope, function_name_lc, fname_len TSRMLS_CC); + } else { + EX(function_state).function = + zend_std_get_static_method(calling_scope, function_name_lc, fname_len TSRMLS_CC); + } efree(function_name_lc); if (check_scope_or_static && EX(function_state).function && !(EX(function_state).function->common.fn_flags & ZEND_ACC_STATIC) diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 5b973cbbd1..311497f5f3 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1778,7 +1778,11 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS function_name_strlen = function_name->value.str.len; } - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + if (ce->get_static_method) { + EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } else { + EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } if (!is_const) { efree(function_name_strval); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 9baff66e72..549d328b74 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -170,7 +170,6 @@ static int zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) zend_ptr_stack_2_push(&EG(argument_stack), (void *)(zend_uintptr_t)opline->extended_value, NULL); EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; -// EX_T(opline->result.u.var).var.fcall_returned_reference = 0; if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) { ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); @@ -2431,7 +2430,11 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HAN function_name_strlen = function_name->value.str.len; } - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + if (ce->get_static_method) { + EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } else { + EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } if (!is_const) { efree(function_name_strval); @@ -2975,7 +2978,11 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDL function_name_strlen = function_name->value.str.len; } - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + if (ce->get_static_method) { + EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } else { + EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } if (!is_const) { efree(function_name_strval); @@ -3419,7 +3426,11 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDL function_name_strlen = function_name->value.str.len; } - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + if (ce->get_static_method) { + EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } else { + EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } if (!is_const) { efree(function_name_strval); @@ -3629,7 +3640,11 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_UNUSED_HANDLER(ZEND_OPCODE_HA function_name_strlen = function_name->value.str.len; } - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + if (ce->get_static_method) { + EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } else { + EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } if (!is_const) { efree(function_name_strval); @@ -4041,7 +4056,11 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLE function_name_strlen = function_name->value.str.len; } - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + if (ce->get_static_method) { + EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } else { + EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } if (!is_const) { efree(function_name_strval); @@ -9619,7 +9638,11 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDL function_name_strlen = function_name->value.str.len; } - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + if (ce->get_static_method) { + EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } else { + EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } if (!is_const) { efree(function_name_strval); @@ -11260,7 +11283,11 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER function_name_strlen = function_name->value.str.len; } - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + if (ce->get_static_method) { + EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } else { + EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } if (!is_const) { efree(function_name_strval); @@ -12873,7 +12900,11 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER function_name_strlen = function_name->value.str.len; } - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + if (ce->get_static_method) { + EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } else { + EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } if (!is_const) { efree(function_name_strval); @@ -13687,7 +13718,11 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HAND function_name_strlen = function_name->value.str.len; } - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + if (ce->get_static_method) { + EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } else { + EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } if (!is_const) { efree(function_name_strval); @@ -15001,7 +15036,11 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ function_name_strlen = function_name->value.str.len; } - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + if (ce->get_static_method) { + EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } else { + EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + } if (!is_const) { efree(function_name_strval);