From 166266df68db50c4d1119f2be265972c8d77f1af Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Sat, 29 Sep 2007 07:28:34 +0000 Subject: Added support for Late Static Binding. (Dmitry, Etienne Kneuss) --- Zend/zend_builtin_functions.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Zend/zend_builtin_functions.c') 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) -- cgit v1.2.1