Imo, just using one or more SPL libraries as an interface is usually less ugly to use on the front panel. However, implementation support can get a little ugly.
For example, I wrote an iterator that effectively repeated a set of database results, so that results that were never queried were never retrieved from the query pointer, and if the elements were prematurely selected (IE: $ obj [5]), this will look for everything necessary results to the internal buffer.
It worked wonderfully, you just pray that the code that makes magic backstage never fail because it confuses people when they see that you are using something like an array, and it does βmagicβ that can fail fail :)
Magic made people burn at the stake. Therefore, use it carefully and wisely, it may be clear how this works.
My personal preferences relate to
for( $object as $i => $v )
the designation for him is usually more consistent and predictable.
for( $dbresult->iterator() as $i => $v ){ }
the style designation is functionally identical, but at least you have less clue how it works on the surface.
source share