On 10/31/16 9:02 AM, Andrea Faulds wrote:
> 
> 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.
> 

I hadn't thought about that particular use case. I also hadn't ever
tried using these functions on non-arrays before I recently attempted
using them with an Iterator.

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

I would think that Reflection would be necessary to get the
private/protected properties, but these functions currently allow
iteration over private/protected properties of an object. This should be
limited to public properties similar to the way foreach is limited. But
that's another issue.

> 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.

As a user it came as a surprise that I couldn't use an Iterator where an
array was being used, as they are used interchangeable in some other
contexts.

I'll also admit that I don't normally read the docs until I have
problems. The behavior with passing objects to those functions is only
documented by a user comment.

Dave
-- 
David Lundgren
dlundg...@syberisle.net
GPG: 0x26F54D7F

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

Reply via email to