On Wed Dec 17 2014 at 1:44:13 PM guilhermebla...@gmail.com < guilhermebla...@gmail.com> wrote:
> Hi, > > Answering the question of Christopher Becker. It is not possible to > traverse and get your desired elements. > How would you achieve a foreach by key (returning object) without having to > store a separate list and track by hash or through an interface? > > Which is one of the main problem with this very RFC. What ends up being stored in the array is the hash, not the object. And there is no immediate way of getting the key object back. The user writes: $arr = array($obj => 2); but key($arr) returns the hash only. As I said in the original discussion: this RFC is actually about having an implicit call to __hash() whenever an object is used as an array key. You can achieve exactly the same in userland with an explicit call. I would rather wait (maybe indefinitely) to have a proper implementation of objects as keys than have this compromise. Best,