diff options
author | Dmitry Stogov <dmitry@php.net> | 2007-09-29 07:28:34 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2007-09-29 07:28:34 +0000 |
commit | 166266df68db50c4d1119f2be265972c8d77f1af (patch) | |
tree | db37ce528d82613d84737d6e30cb8fe8f14c9b78 /Zend/zend_builtin_functions.c | |
parent | e9dd6fab9194b3ae717b79322853dfa6fb64fb28 (diff) | |
download | php-git-166266df68db50c4d1119f2be265972c8d77f1af.tar.gz |
Added support for Late Static Binding. (Dmitry, Etienne Kneuss)
Diffstat (limited to 'Zend/zend_builtin_functions.c')
-rw-r--r-- | Zend/zend_builtin_functions.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index d4ead902ba..9a64ea72e4 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -43,6 +43,7 @@ static ZEND_FUNCTION(error_reporting); static ZEND_FUNCTION(define); static ZEND_FUNCTION(defined); static ZEND_FUNCTION(get_class); +static ZEND_FUNCTION(get_called_class); static ZEND_FUNCTION(get_parent_class); static ZEND_FUNCTION(method_exists); static ZEND_FUNCTION(property_exists); @@ -103,6 +104,7 @@ static const zend_function_entry builtin_functions[] = { ZEND_FE(define, NULL) ZEND_FE(defined, NULL) ZEND_FE(get_class, NULL) + ZEND_FE(get_called_class, NULL) ZEND_FE(get_parent_class, NULL) ZEND_FE(method_exists, NULL) ZEND_FE(property_exists, NULL) @@ -584,6 +586,25 @@ ZEND_FUNCTION(get_class) /* }}} */ +/* {{{ proto string get_called_class() + Retrieves the "Late Static Binding" class name */ +ZEND_FUNCTION(get_called_class) +{ + if (!ZEND_NUM_ARGS()) { + if (EG(called_scope)) { + RETURN_STRINGL(EG(called_scope)->name, EG(called_scope)->name_length, 1); + } else { + zend_error(E_WARNING, "get_called_class() called from outside a class"); + RETURN_FALSE; + } + } else { + ZEND_WRONG_PARAM_COUNT(); + RETURN_FALSE; + } +} +/* }}} */ + + /* {{{ proto string get_parent_class([mixed object]) Retrieves the parent class name for object or class or current scope. */ ZEND_FUNCTION(get_parent_class) |