> Still looking ... for a solution to the ZF factory puzzle.
I eventually came up with this syntax for calling factories:
$foo = factory()->Some_Class->singleton();
Where previously I would have used:
$foo = Some_Class::singleton();
'factory()' is a special function which returns an object which uses __get()
and __call() to handle 'Some_Class' and 'singleton', and does a
'call_user_func()' on the real Some_Class::singleton() method.
In this way, I can also use:
$foo = factory()->$className->singleton();
or
$foo = factory()->Some_Class->$factoryMethod();
... and the 'factory()' function has a way of emulating static function
inheritance as well (which won't be possible until PHP6, last I heard).
So this solution dealt with a couple of issues
- '$className::singleton()' isn't possible yet in PHP.
- static functions can't be inherited properly yet (they aren't aware of the
extending class).
Now that I think about it, depending on how complex the existing Code
Completion tools are, they might actually be able to detect the class name by
investigating phpDocumentor comments (I have no way to try this myself).
regards,
Peter
____________________________________________________
On Yahoo!7
Messenger - IM with Windows LiveĀ Messenger friends.
http://au.messenger.yahoo.com