From: thenewparadigm at hotmail dot com
Operating system: Windows 98SE
PHP version: 5CVS-2005-03-09 (dev)
PHP Bug Type: Zend Engine 2 problem
Bug description: self:: syntax cannot be used transparently if used in
inherited class functions
Description:
------------
Object oriented code utilizing the self:: syntax does not function
transparently when a class calls one of its inherited methods given that
self:: always refers to the class in which it is used, without regard to
the context in which it is used.
Classes are unable to use their own static methods and variables in any
way when accessed through inherited methods or overridden methods called
using the parent:: syntax without explicitly calling the class method or
variable by using the class name with the :: operator; eg
MyClass::desiredMethod();
This bug applies to all PHP 5.x.x builds thus far. I have confirmed the
bug in both modified php.ini and php.ini-dist configurations using Apache
1.3.31.
Reproduce code:
---------------
class parentClass {
public static function methodOne() {
self::methodTwo();
}
public static function methodTwo() {
echo "methodTwo as defined in parentClass\n";
}
}
class childClass extends parentClass {
public static function methodTwo() {
echo "methodTwo as defined in childClass\n";
}
}
parentClass::methodOne();
childClass::methodOne();
Expected result:
----------------
The following output was expected:
methodTwo as defined in parentClass
methodTwo as defined in childClass
I expected methodOne in the parentClass to call methodTwo as defined in
the calling class, as would be done if using the -> operator with
non-static methods.
Actual result:
--------------
The following output was generated by the code:
methodTwo as defined in parentClass
methodTwo as defined in parentClass
At the moment, the only way to make the code work as expected is to define
methodOne in childClass, purely identical to the one already found in
parentClass.
--
Edit bug report at http://bugs.php.net/?id=32240&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32240&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=32240&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=32240&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32240&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32240&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32240&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32240&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32240&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32240&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32240&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=32240&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=32240&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32240&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32240&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32240&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32240&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32240&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32240&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32240&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32240&r=mysqlcfg