diff options
author | Stanislav Malyshev <stas@php.net> | 2003-06-09 10:55:37 +0000 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2003-06-09 10:55:37 +0000 |
commit | 565985acfc5ab1b25d283d72e2836e337c492514 (patch) | |
tree | ef8fe7c5e1ac3b4e821da024242b86db662dae05 | |
parent | e7fd4c57b24d044e522d3a2bfd3d7424c5af5577 (diff) | |
download | php-git-565985acfc5ab1b25d283d72e2836e337c492514.tar.gz |
Support 'self' and 'parent' in call_user_func()
-rw-r--r-- | Zend/zend_API.c | 7 | ||||
-rw-r--r-- | Zend/zend_execute_API.c | 12 |
2 files changed, 16 insertions, 3 deletions
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; |