From 4efbb350678c682a4d341f4464baa7063dcf3342 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Sun, 14 Mar 2004 22:40:25 +0000 Subject: [PATCH] Make object parameter optional --- Zend/zend_builtin_functions.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index fbb6f46eacc..93c02f50211 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(); }