From b52ab41ca773d1e1c779ce8583290a4587b032e4 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Thu, 14 Oct 2004 07:26:04 +0000 Subject: [PATCH] - Allow to omit object/classname in get_parent_class() which makes it compatible with the signature and behavior of get_class() --- Zend/zend_builtin_functions.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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(); } -- 2.50.1