From: Marcus Boerger Date: Sun, 14 Mar 2004 22:40:25 +0000 (+0000) Subject: Make object parameter optional X-Git-Tag: php-5.0.0RC1RC1~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4efbb350678c682a4d341f4464baa7063dcf3342;p=php Make object parameter optional --- diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index fbb6f46eac..93c02f5021 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -514,7 +514,7 @@ ZEND_FUNCTION(defined) /* }}} */ -/* {{{ proto string get_class(object object) +/* {{{ proto string get_class([object object]) Retrieves the class name */ ZEND_FUNCTION(get_class) { @@ -522,6 +522,13 @@ ZEND_FUNCTION(get_class) char *name = ""; zend_uint name_len = 0; + if (!ZEND_NUM_ARGS()) { + if (EG(scope)) { + RETURN_STRINGL(EG(scope)->name, EG(scope)->name_length, 1); + } else { + zend_error(E_ERROR, "get_class() called without object from outside a class"); + } + } if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &arg)==FAILURE) { ZEND_WRONG_PARAM_COUNT(); }