Re: [VOTE] Making stdClass iterable
| From: | Levi Morrison | Date: | Tue, 05 Feb 2019 16:39:20 +0000 |
| Subject: | Re: [VOTE] Making stdClass iterable | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-104195@lists.php.net to get a copy of this message | ||
On Mon, Feb 4, 2019 at 11:58 AM Craig Duncan <php@duncanc.co.uk> wrote:
>
> Hi all,
>
> Following the discussion it's now time to vote on whether we make the
> stdClass iterable or not.
> https://wiki.php.net/rfc/iterable-stdclass
>
> Note that while there is an implementation available, the vote is only on
> whether stdClass should fulfil the Traversable interface or not.
> Nikita had some ideas on a different implementation that I'll revisit if
> the vote passes.
>
> Voting will end in two weeks on 2019-02-18
>
> Thanks to everybody that shared their opinion and raised concerns during
> the discussion.
>
> Craig
I just wanted to pipe in to suggest an alternative approach to
accomplish some of the same goals: an external PropertyIterator.
- It could allow us to refine which property visibilities we care to
iterate over. For instance, if we are in a protected or private
context we may want to still only iterate over public properties.
- I think that with typed properties we will see more data-only
classes which would benefit from an external PropertyIterator.
Of course, that still means
stdClass isn't automatically iterable,
but if you want it to be then you can pass in a PropertyIterator
instead.