From:             pornel at despammed dot com
Operating system: *
PHP version:      5.1.0RC1
PHP Bug Type:     Feature/Change Request
Bug description:  late binding for static calls

Description:
------------
In PHP it is not possible to write base class for singleton and similar
programming patterns.

I know it is intended behavior and backwards compatibility may make
changes difficult, but there is significant number of complaints about
current implementation:
http://bugs.php.net/bug.php?id=30235
http://bugs.php.net/bug.php?id=30934
http://bugs.php.net/bug.php?id=30423
http://bugs.php.net/bug.php?id=19376
http://bugs.php.net/bug.php?id=26930
http://bugs.php.net/bug.php?id=28442
http://bugs.php.net/bug.php?id=29647

and I'd like to add another one.

I'm trying to write functionality that works similar to ActiveRow
implementation in RubyOnRails, but the way in which PHP handles static
methods and inheritance makes such implementation impossible.

I hope you could implement late binding for static calls and fields. 

It could be used with this:: construct instead of self::, which may be
emulated for backwards compatiblity.


Reproduce code:
---------------
class Base
{
  static function test1() {self::test2();}
  static function test2() {echo 'failure';}
}

class Child
{
  static function test2() {echo 'success';}
}

Child::test();


Expected result:
----------------
success

Actual result:
--------------
failure


backtrace doesn't contain reference to Child class (that would be enough
for a workaround).


-- 
Edit bug report at http://bugs.php.net/?id=34703&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=34703&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=34703&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=34703&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=34703&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=34703&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=34703&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=34703&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=34703&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=34703&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=34703&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=34703&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=34703&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=34703&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=34703&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=34703&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=34703&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=34703&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=34703&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=34703&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=34703&r=mysqlcfg

Reply via email to