From:             sam at ombwa dot com
Operating system: Win2K
PHP version:      5CVS-2005-12-04 (snap)
PHP Bug Type:     Class/Object related
Bug description:  get_class() and get_class($this) inconsistent in inherited 
functions

Description:
------------
In an inherited function,
get_class()      gives the name of the parent class
get_class($this) gives the name of the child class.
These should be consistent and return the name of the child class.

Before you get deja vu and mark this bogus, I think that 31716 and 31616
were closed improperly as they deal with inheitance, NOT static isuses
like 30964/30140.

Reproduce code:
---------------
<?php
class Parentclass {
    function inherited_func() {
        echo "In inherited_func():\n__CLASS__ = " .     __CLASS__ .
"\nget_class() = " . get_class()      . "\nget_class(\$this) = " .
get_class($this) . "\n";
    }
}

class Childclass extends Parentclass {
    function func() {
        echo "In func():\n__CLASS__ = " . __CLASS__ . "\nget_class() = " .
get_class()      . "\nget_class(\$this) = " . get_class($this) . "\n";
    }
}
$c = new Childclass();
echo "<pre> phpversion()=" . phpversion() . "\n";
$c->func();
$c->inherited_func();
?>

Expected result:
----------------
I expect get_class() and get_class($this) to return "Childclass".

Actual result:
--------------
 phpversion()=5.1.2-dev
In func():
__CLASS__ = Childclass
get_class() = Childclass
get_class($this) = Childclass
In inherited_func():
__CLASS__ = Parentclass
get_class() = Parentclass
get_class($this) = Childclass

-- 
Edit bug report at http://bugs.php.net/?id=35540&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=35540&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=35540&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=35540&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=35540&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=35540&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=35540&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=35540&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=35540&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=35540&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=35540&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=35540&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=35540&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=35540&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=35540&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=35540&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=35540&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=35540&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=35540&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=35540&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=35540&r=mysqlcfg

Reply via email to