#38081 [Opn->Bgs]: Change to "resolving static method calls at compile time"

From: Date: Thu, 13 Jul 2006 09:52:33 +0000
Subject: #38081 [Opn->Bgs]: Change to "resolving static method calls at compile time"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-99393@lists.php.net to get a copy of this message
ID: 38081 Updated by: helly@php.net Reported By: andres at pruna dot com dot ar -Status: Open +Status: Bogus Bug Type: Feature/Change Request -Operating System: any +Operating System: * -PHP Version: 5.1.4 +PHP Version: 5.* New Comment: as you said dupe Previous Comments: ------------------------------------------------------------------------ [2006-07-12 15:02:41] andres at pruna dot com dot ar Description: ------------ In the manual (http://ar2.php.net/manual/en/language.oop5.static.php), is properly documented that: " 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. " I'm not arguing if it's correct from OO point of view or not. I say it's a little bit annoying, I don't found any case when this could help, and, instead, there's a lot of requests to change or workaround it (as from comments in this page, in other Feature Requests like 30934, 37052, ...). In fact, I think that fixing (or "changing") it, would alow to add a new pattern to manual. :) Anyway, it would help to know what to expect about it. Reproduce code: --------------- abstract class Parent { static public function doSomething($var) { self::howToReallyDoIt($var); } abstract protected function howToReallyDoIt($var); } class Child extends Parent { protected function howToReallyDoIt($var) { // implementation for Child ... echo $var; } } Child::doSomething('hello'); Expected result: ---------------- hello Actual result: -------------- Fatal error: Cannot call abstract method Parent::howToReallyDoIt() in ... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38081&edit=1

« previous php.bugs (#99393) next »