ID: 39232 User updated by: bugs dot php dot net at nanonanonano dot net Reported By: bugs dot php dot net at nanonanonano dot net Status: Closed Bug Type: Documentation problem Operating System: all PHP Version: Irrelevant New Comment:
Excellent, thanks! Previous Comments: ------------------------------------------------------------------------ [2007-08-17 12:39:51] [EMAIL PROTECTED] No such paragraph on this page now. ------------------------------------------------------------------------ [2006-10-23 09:18:07] bugs dot php dot net at nanonanonano dot net Description: ------------ In the fourth paragraph of documentation page: http://php.net/language.oop5.static the following appears: "In fact static method calls are resolved at compile time. When using an explicit class name the method is already identified completely and no inheritance rules apply. If the call is done by self then self is translated to the current class, that is the class the code belongs to. Here also no inheritance rules apply." This is incorrect under PHP5 (tested under PHP 5.1.6) -- but I think this is just a confusion between inheritance and polymorphism in the documentation. Static methods and members *are* inherited and can be called through sub classes (as in the example code on the documentation page in question and the example given below). Static methods do not, however, behave polymorphically (there is no polymorphism in a static call as the caller is being specific about which version of the function to use and overloaded static functions are not permitted in PHP). Reproduce code: --------------- <?php class Foo { static function a() { echo "Foo::a"; } } class Bar extends Foo { } Bar::a(); Expected result: ---------------- According to the documentation, "no inheritance rules apply" so it should give an undefined function error: "Fatal error: Call to undefined method Bar::a() in /tmp/statictest.php on line 11" Actual result: -------------- Foo::a (Note: I don't necessarily expect that the documentation will launch into a long lecture about inheritance and polymorphism in order to clear this up... but the documentation currently implies that something can't be done that actually can be done.) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39232&edit=1