diff options
author | Zeev Suraski <zeev@php.net> | 2003-08-03 08:21:08 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 2003-08-03 08:21:08 +0000 |
commit | 9d7122fb53fd7f043f2cde7eeb4f9aa0e2115adf (patch) | |
tree | a978e8d04915e4df8a3ae1f1524ebcc55f1aed7a /Zend/zend_execute_API.c | |
parent | 973b85672b4af12e8cb50376d89149b358c484f5 (diff) | |
download | php-git-9d7122fb53fd7f043f2cde7eeb4f9aa0e2115adf.tar.gz |
Generalize fetch_class
Diffstat (limited to 'Zend/zend_execute_API.c')
-rw-r--r-- | Zend/zend_execute_API.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 78c35d56f4..d57ac934db 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1049,6 +1049,43 @@ void zend_unset_timeout(TSRMLS_D) #endif } + +zend_class_entry *zend_fetch_class(char *class_name, uint class_name_len, int fetch_type TSRMLS_DC) +{ + zend_class_entry **pce; + zend_class_entry *ce = NULL; + zend_bool free_class_name = 0; + +check_fetch_type: + switch (fetch_type) { + case ZEND_FETCH_CLASS_SELF: + if (!EG(scope)) { + zend_error(E_ERROR, "Cannot access self:: when no class scope is active"); + } + return EG(scope); + case ZEND_FETCH_CLASS_PARENT: + if (!EG(scope)) { + zend_error(E_ERROR, "Cannot access parent:: when no class scope is active"); + } + if (!EG(scope)->parent) { + zend_error(E_ERROR, "Cannot access parent:: when current class scope has no parent"); + } + return EG(scope)->parent; + case ZEND_FETCH_CLASS_AUTO: { + fetch_type = zend_get_class_fetch_type(class_name, class_name_len); + if (fetch_type!=ZEND_FETCH_CLASS_DEFAULT) { + goto check_fetch_type; + } + } + break; + } + + if (zend_lookup_class(class_name, class_name_len, &pce TSRMLS_CC)==FAILURE) { + zend_error(E_ERROR, "Class '%s' not found", class_name); + } + return *pce; +} + /* * Local variables: * tab-width: 4 |