From: ms419 at freezone dot co dot uk
Operating system: Debian
PHP version: 5.2.5
PHP Bug Type: Class/Object related
Bug description: self doesn't refer to the class from which i called a static
function
Description:
------------
When I call Bar::aaa(); I expect the self keyword to refer to the Bar
class, even if aaa() is defined in a class which Bar extends.
The behavior I observe is that, if aaa() is defined in a class Foo which
Bar extends, even when I call Bar::aaa(), self refers to Foo.
In this case the self keyword is not actually that much use, since if I
type "self" in the definition of the Foo class, I know the class name and
might as well type "Foo".
I had hoped that the self keyword would enable me to override some static
functions from a parent class, without forcing me to override the static
functions which call them.
Reproduce code:
---------------
<?php
class Foo
{
public static function aaa()
{
return self::bbb();
}
public static function bbb()
{
return 'Foo';
}
}
class Bar extends Foo
{
public static function bbb()
{
return 'Bar';
}
}
var_dump(Bar::aaa());
Expected result:
----------------
string(3) "Bar"
Actual result:
--------------
string(3) "Foo"
--
Edit bug report at http://bugs.php.net/?id=44011&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=44011&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=44011&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=44011&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=44011&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44011&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=44011&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44011&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44011&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44011&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44011&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44011&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=44011&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=44011&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44011&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=44011&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=44011&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44011&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44011&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44011&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44011&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44011&r=mysqlcfg