PHP 5 foreach iterators for COM

From: Date: Tue, 07 Oct 2003 13:48:17 +0000
Subject: PHP 5 foreach iterators for COM
Groups: php.internals 
Request: Send a blank email to internals+get-4728@lists.php.net to get a copy of this message
I need some kind of engine hook to allow this kind of code in the COM extension: foreach ($container as $child) { echo $child->name; } The way this works in COM is like this: foreach fetches the magic iterator property from $container. The magic iterator is an instance of IEnumXXX, where XXX is most likely Variant, but could be anything. It then repeatedly calls $iterator->Next() to fetch the next item. When done, it releases the $iterator. I know Marcus implemented iterators for spl, but the concept there is that the $container itself needs to implement spl interfaces. The just doesn't fit with the way COM stuff works, and pollutes the COM object with magic (some COM objects want to handle method and property accesses by magic themselves). Can we have a extra handler in the object handlers struct that returns an object that implements an engine-supported iterator? --Wez.

« previous php.internals (#4728) next »