From: Stanislav Malyshev Date: Mon, 9 Jun 2003 10:55:37 +0000 (+0000) Subject: Support 'self' and 'parent' in call_user_func() X-Git-Tag: RELEASE_1_0_2~343 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=565985acfc5ab1b25d283d72e2836e337c492514;p=php Support 'self' and 'parent' in call_user_func() --- diff --git a/Zend/zend_API.c b/Zend/zend_API.c index c420aebf6d..5a6e373ab9 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1504,7 +1504,12 @@ zend_bool zend_is_callable(zval *callable, zend_bool syntax_only, char **callabl return 1; lcname = zend_str_tolower_dup(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj)); - if (zend_lookup_class(lcname, Z_STRLEN_PP(obj), &pce TSRMLS_CC) == SUCCESS) { + + if(EG(active_op_array) && strcmp(lcname, "self") == 0) { + ce = EG(active_op_array)->scope; + } else if(strcmp(lcname, "parent") == 0 && EG(active_op_array) && EG(active_op_array)->scope) { + ce = EG(active_op_array)->scope->parent; + } else if (zend_lookup_class(lcname, Z_STRLEN_PP(obj), &pce TSRMLS_CC) == SUCCESS) { ce = *pce; } diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 751e3919b6..0e05ddbc9e 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -583,10 +583,18 @@ int fast_call_user_function(HashTable *function_table, zval **object_pp, zval *f } else if (Z_TYPE_PP(object_pp) == IS_STRING) { zend_class_entry **ce; char *lc_class; - int found; + int found = FAILURE; lc_class = zend_str_tolower_dup(Z_STRVAL_PP(object_pp), Z_STRLEN_PP(object_pp)); - found = zend_lookup_class(lc_class, Z_STRLEN_PP(object_pp), &ce TSRMLS_CC); + if(EG(active_op_array) && strcmp(lc_class, "self") == 0) { + ce = &(EG(active_op_array)->scope); + found = (*ce != NULL?SUCCESS:FAILURE); + } else if(strcmp(lc_class, "parent") == 0 && EG(active_op_array) && EG(active_op_array)->scope) { + ce = &(EG(active_op_array)->scope->parent); + found = (*ce != NULL?SUCCESS:FAILURE); + } else { + found = zend_lookup_class(lc_class, Z_STRLEN_PP(object_pp), &ce TSRMLS_CC); + } efree(lc_class); if (found == FAILURE) return FAILURE;