#38081 [Bgs]: Change to "resolving static method calls at compile time"
ID: 38081
User updated by: andres at pruna dot com dot ar
Reported By: andres at pruna dot com dot ar
Status: Bogus
Bug Type: Feature/Change Request
Operating System: *
PHP Version: 5.*
New Comment:
Helly, we all understand that it's expected behavoir. However, loosing
inheritance in static calls, also make us loose flexibility. Is there
any plan to modify this? I can't comment on other bugs, as they are
"Bogus", and I can't find any place where you say if it's planned to be
changed or not.
Previous Comments:
------------------------------------------------------------------------
[2006-07-13 09:52:33] helly@php.net
as you said dupe
------------------------------------------------------------------------
[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
Thread (3 messages)