ID:               30934
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jbs at fromru dot com
 Status:           Assigned
 Bug Type:         Class/Object related
 Operating System: *
 PHP Version:      5.0.3
 Assigned To:      andi
 New Comment:

I think this really needs to be addressed. For example the php manual
features a sample singleton implementation:
http://www.php.net/manual/en/language.oop5.patterns.php

Now how would one go about making it possible to extend the "Example"
class without having to cut and paste the singleton() method to this
extended class (one would probably also need to the instance property
to hold an array of instances keyed be the class name)? Not exactly in
the spirit of OOP imho.

It seems to me the best solution to retain this "speed optimization" of
resolving these things at compile time is to copy the implementations of
static items over to classes that extend that class before this
evaluation is done. Just a thought from an outside perspective, dunno
if this is feasible however in the ZE2 implementation.


Previous Comments:
------------------------------------------------------------------------

[2005-04-11 23:14:42] aknaub at 3st dot de

Sorry, but this quote is nonsense. Every real OOP 
language (Ruby, ObjC etc.) resolves static methods at 
runtime.

------------------------------------------------------------------------

[2005-04-11 13:50:15] jbs at fromru dot com

I've noticed some similar reports. For example, the one at
http://bugs.php.net/bug.php?id=30235.

Here is a quote:
>
> Sorry, you have a complete wrong idea og OO programming.
>
> Static methods are bound/resolved at compile time.
> That is the compiler can replace self with the current
> class.
>

So, it appears as it is a limitation of the compiler and the entire
object model.

I think such behavior makes inheritance of static methods useless
because even if a static method is inherited, it still functions as in
the class where it was declared. Moreover, inherited static methods are
using the static properties which were declared in the parent class but
not the inherited one.

So, in my opinion "self" keyword should be replaced with the name of
the inherited class during compiling. Or at least a new magic keyword
should be added and named like "this", for example.

------------------------------------------------------------------------

[2005-03-30 23:47:28] [EMAIL PROTECTED]

Andi, is this a bug or not?


------------------------------------------------------------------------

[2005-03-29 09:10:20] aknaub at 3st dot de

I reproduced the bug with snapshot php5-200503282030, 
compiled as cli on Mac OS X 10.3.8.

------------------------------------------------------------------------

[2005-03-27 01:18:39] mongole at tuivelsminne dot at

I reproduced the bug with snapshot php5-200503262330, compiled as
mod_php in apache-1.3.33 on FC 3.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/30934

-- 
Edit this bug report at http://bugs.php.net/?id=30934&edit=1

Reply via email to