On Tue, 5 Feb 2019 at 17:25, Craig Duncan <[email protected]> wrote:
> The *iterable* type accepts a plain array, but not an object that is used
> to represent a plain array, that's surprising to me.
>
I think this notion of stdClass as "an object used to represent a plain
array" is a peculiar one. The only reason I can think of for using stdClass
is to specifically *not* be like an array in some way.
As I mentioned in the discussion thread, the closer comparison would be to
an anonymous class: $foo = new stdClass; and $foo = new class {}; both
produce objects with no behaviour, no pre-defined methods, and the ability
to define properties dynamically.
On that definition, there's no surprise at all: it's an object that has no
defined behaviour, so is not defined as having the "iterable" behaviour.
> To me, this class is presented as a first class citizen, but it works like
> a second class one.
>
While I agree that it's an anomaly in many ways, I think the fact that it's
not marked iterable is a peculiar detail to get stuck on.
Regards,
--
Rowan Collins
[IMSoP]