Hello Hans,

Thursday, February 19, 2004, 4:14:53 PM, you wrote:


> Timm Friebe wrote:
>> On Wed, 2004-02-18 at 18:40, Hans Lellelid wrote:
>> 
>>>foreach($entities as $ent) {
>>>     $peer = $ent->getPeer(); // e.g. might be BookPeer
>>>     $peer->doSelect(new Criteria()); //static: BookPeer::doSelect()
>>>}
>> 
>> 
>> $m= new Reflection_Method($ent->getPeer(), 'doSelect');
>> $m->invoke(NULL, new Criteria());
>> 
>> /* untested */
>> 

> Yeah, I'm sure there's a way to get something like that to work also. 
> I'm not sure that's prefereable to call_user_func(), honestly -- and it 
> doesn't get around the basic problem which is that calling code needs to 
> know whether methods are static.

> I guess I'm not sure why this is necessary ...

> As Hartmut & Lukas mention, I don't know why the class consumer *needs* 
> to know that it's static.  Clearly internally there should be no 
> possibility of referencing $this.

> Also in my example the entire class is static -- i.e. all methods are 
> static -- but what about cases where one or two methods in a class are 
> static.  Now $a->methodName() will work for most but all of a sudden you 
> have to do $a::staticMethodName() for the static members.

> What I see as the workaround is creating static methods that aren't 
> marked as static -- e.g. that would address the issue in my example 
> above.  I think that's a lot worse than allowing invocation of static 
> methods using instances, however, because I do want developers who read 
> the API docs to know these are static functions.

I hope nobody wants such strange things. Calling a static method from
an instance is just one of the ways to get to the class of that method.


-- 
Best regards,
 Marcus                            mailto:[EMAIL PROTECTED]

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to