You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now if you try to unpack an object, you will get an error: Only arrays and Traversables can be unpacked.
But if you just foreach an object, it works, and you can iterate over each public property, so I think unpacking should work on all objects and return public properties. This would be especially nice when working with stdClass or DTO.
And take a look at an example where objects share some properties
Hi @MrMeshok! Thank you for the suggestion. Language changes require RFCs, and while we do allow feature requests on the bug tracker, they often don't go anywhere. The proactive thing would be to start a discussion on the internals mailing list, to see if there's interest in this change. Is that something you're interested in doing?
Description
Right now if you try to unpack an object, you will get an error:
Only arrays and Traversables can be unpacked.
But if you just foreach an object, it works, and you can iterate over each public property, so I think unpacking should work on all objects and return public properties. This would be especially nice when working with stdClass or DTO.
And take a look at an example where objects share some properties
Right now workaround is to use ...(array) $balance or implement IteratorAggregate on classes
The text was updated successfully, but these errors were encountered: