From: jbs at fromru dot com
Operating system: Windows XP Pro SP1
PHP version: 5.0.2
PHP Bug Type: Class/Object related
Bug description: Special keyword 'self' inherited in child classes
Description:
------------
Special keyword 'self' represents the parent class instead of the child
class when it is used in an inherited method of the parent class.
Reproduce code:
---------------
class Foo {
const NAME = 'Foo';
static public function display() {
echo self::NAME;
}
static public function getInstance() {
$instance = new self;
return $instance;
}
}
class Child extends Foo {
const NAME = 'Child';
}
echo('Class constant: ');
Child::display();
echo('<BR>Object class: ');
echo(get_class(Child::getInstance()));
Expected result:
----------------
Class constant: Child
Object class: Child
Actual result:
--------------
Class constant: Foo
Object class: Foo
--
Edit bug report at http://bugs.php.net/?id=30934&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30934&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=30934&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=30934&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=30934&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=30934&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=30934&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=30934&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=30934&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=30934&r=support
Expected behavior: http://bugs.php.net/fix.php?id=30934&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=30934&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=30934&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=30934&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30934&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=30934&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=30934&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=30934&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=30934&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=30934&r=mysqlcfg