Improve warning message in Set::toArray()
commita1693289e29f2c8d0b5b8c8d792ebfd3ada3381b
authorAbel Nieto <anietoro@fb.com>
Tue, 17 Dec 2013 19:44:54 +0000 (17 11:44 -0800)
committerSara Golemon <sgolemon@fb.com>
Tue, 17 Dec 2013 21:59:05 +0000 (17 13:59 -0800)
treecddcc3b5721b41b48fbed99cba1ea5fdc5ca0154
parentd91fae6ae5a08158db2fb62cf89a3784b0352629
Improve warning message in Set::toArray()

Array has a weird behaviour where string keys that can be represented
as ints are automagically converted to ints. From the manual:

  A key may be either an integer or a string. If a key is the standard
  representation of an integer, it will be interpreted as such (i.e.
  "8" will be interpreted as 8, while "08" will be interpreted as "08").

Since Set can contain both ints and strings, we could have e.g.

  $s = Set {1, '1'}

Calling $s->toArray() gives back then a 1-element array.

We were previously raising a warning in this case, but the warning didn't
specify what was the value of the "duplicate" key. Do so.

Reviewed By: @jdelong

Differential Revision: D1096274
hphp/runtime/ext/ext_collections.cpp
hphp/runtime/ext/ext_collections.h
hphp/test/quick/set_toarray_warn.php [new file with mode: 0644]
hphp/test/quick/set_toarray_warn.php.expectf [new file with mode: 0644]
hphp/test/slow/collection_classes/803.php.expectf
hphp/util/hash.h