Hi, All I can say is that the lack of this feature is one of the main reasons why Doctrine doesn't fully work with composite keys. With this enhancement it would now become possible to implement a proper IdentityMap.
[]s, On Dec 16, 2014, at 9:05 AM, Andrea Faulds <a...@ajf.me> wrote: >> >> On 16 Dec 2014, at 10:52, Andrea Faulds <a...@ajf.me> wrote: >> >> Exactly. If I were to do this: >> >> <?php >> class Foo { >> public $foo; >> function __construct($foo) { >> $this->foo = $foo; >> } >> function __toKey() { >> return $this->foo; >> } >> } >> $arr = []; >> $arr[] = new Foo(1); >> var_dump($arr); >> >> I would get this: >> >> array(1) { >> [0]=> >> int(1) >> } > > Er, a correction… the example should’ve been something like this: > > $arr = []; > $arr[new Foo(1)] = NULL; > > Producing this: > > array(1) { > [1]=> > NULL > } > > Obviously, it has no effect on values, only keys, sorry! > > -- > Andrea Faulds > http://ajf.me/ > > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php