Skip to content

Standard object iterator #30

@lindyhopchris

Description

@lindyhopchris

The iterator on StandardObject does not recognise stdClass (as it is not a traversable).

This means whenever iterating over a standard object, it is always turned into an array. The problem here is that this means any nested objects are also converted into arrays, so the iteration value is not as expected.

See here:
https://github.com/cloudcreativity/json-api/blob/master/src/Object/StandardObject.php#L89-L96

It would be better to iterate, probably using a generator, and any values that are objects should be wrapped in a standard object. I.e. keep it consistent that objects are cast to the standard object interface.

This fix will however be breaking as it could have unintended consequences on existing code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions