From: Marcus Boerger Date: Thu, 14 Oct 2004 07:26:04 +0000 (+0000) Subject: - Allow to omit object/classname in get_parent_class() which makes it X-Git-Tag: PRE_NEW_VM_GEN_PATCH~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b52ab41ca773d1e1c779ce8583290a4587b032e4;p=php - Allow to omit object/classname in get_parent_class() which makes it compatible with the signature and behavior of get_class() --- diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 2e7eb79b8e..78de5a5cda 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -555,8 +555,8 @@ ZEND_FUNCTION(get_class) /* }}} */ -/* {{{ proto string get_parent_class(mixed object) - Retrieves the parent class name for object or class. */ +/* {{{ proto string get_parent_class([mixed object]) + Retrieves the parent class name for object or class or current scope. */ ZEND_FUNCTION(get_parent_class) { zval **arg; @@ -564,6 +564,14 @@ ZEND_FUNCTION(get_parent_class) char *name; zend_uint name_length; + if (!ZEND_NUM_ARGS()) { + ce = EG(scope); + if (ce && ce->parent) { + RETURN_STRINGL(ce->parent->name, ce->parent->name_length, 1); + } else { + RETURN_FALSE; + } + } if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &arg)==FAILURE) { ZEND_WRONG_PARAM_COUNT(); }