#38081 [NEW]: Change to "resolving static method calls at compile time"
| From: | andres at pruna dot com dot ar | Date: | Wed, 12 Jul 2006 15:02:41 +0000 |
| Subject: | #38081 [NEW]: Change to "resolving static method calls at compile time" | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-99368@lists.php.net to get a copy of this message | ||
From: andres at pruna dot com dot ar
Operating system: any
PHP version: 5.1.4
PHP Bug Type: Feature/Change Request
Bug description: Change to "resolving static method calls at compile time"
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 bug report at http://bugs.php.net/?id=38081&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38081&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38081&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38081&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=38081&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=38081&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=38081&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=38081&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=38081&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=38081&r=support
Expected behavior: http://bugs.php.net/fix.php?id=38081&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=38081&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=38081&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=38081&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38081&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=38081&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=38081&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=38081&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=38081&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=38081&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=38081&r=mysqlcfg