#32240 [Opn->Bgs]: self:: syntax cannot be used transparently if used in inherited class functions
| From: | tony2001@php.net | Date: | Wed, 30 Mar 2005 17:14:53 +0000 |
| Subject: | #32240 [Opn->Bgs]: self:: syntax cannot be used transparently if used in inherited class functions | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-76071@lists.php.net to get a copy of this message | ||
ID: 32240
Updated by: tony2001@php.net
Reported By: thenewparadigm at hotmail dot com
-Status: Open
+Status: Bogus
Bug Type: Zend Engine 2 problem
Operating System: Windows 98SE
PHP Version: 5CVS-2005-03-09 (dev)
New Comment:
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same.
Thank you for your interest in PHP.
See bug #30934.
Previous Comments:
------------------------------------------------------------------------
[2005-03-09 01:17:57] thenewparadigm at hotmail dot com
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 this bug report at http://bugs.php.net/?id=32240&edit=1