]> granicus.if.org Git - php/commitdiff
- Allow to omit object/classname in get_parent_class() which makes it
authorMarcus Boerger <helly@php.net>
Thu, 14 Oct 2004 07:26:04 +0000 (07:26 +0000)
committerMarcus Boerger <helly@php.net>
Thu, 14 Oct 2004 07:26:04 +0000 (07:26 +0000)
  compatible with the signature and behavior of get_class()

Zend/zend_builtin_functions.c

index 2e7eb79b8edfd142451a8d4131c7a6bdbfa7fa8f..78de5a5cdafe56178f5ce57f9392dd97da22d285 100644 (file)
@@ -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();
        }