Hi David,

David Lundgren wrote:
As suggested by several reviewers of a PR[1] I recently submitted, I'd
like to get feedback on letting custom Iterators be used in the current,
next, reset, and key functions. If this is something to move forward
with, I'll need some help with the RFC process.

Recent experiences trying to use these functions with a custom Iterator,
and a bug[2], led me to try and fix this. BC will occur when an object
implementing Iterator is passed to one of the functions, as the
interface methods will be called, instead of returning the objects
properties. The old behavior should be maintained for classes that do
not implement Iterator.

A concern that strikes me is that it's possible some existing code uses these functions precisely because they don't support Iterators, because the author wants to iterate over an object's properties.

What would be the proposed alternative in that case? Reflection?

I think it's unfortunate that PHP has two iteration behaviours for objects, namely iterating over properties, and custom iterators. I think those ought to be separate, rather than the latter overriding the former.

Thanks!

--
Andrea Faulds
https://ajf.me/

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

Reply via email to