Make preg_match return darray instead of PHP array
commit30a7d2af4ab75b3db7387559be15e47922bc7d3d
authorMarcy Park <marcypark@fb.com>
Fri, 13 Jul 2018 00:32:20 +0000 (12 17:32 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Fri, 13 Jul 2018 00:47:44 +0000 (12 17:47 -0700)
treefccbeb177cb39b139f2f07db33171fb4e7a8d129
parentd4a6e06031d72416d370a9d7c99b0a7d07b89cc5
Make preg_match return darray instead of PHP array

Summary:
Goal: Make `preg_match_impl` (and in turn `preg_match` and `preg_match_all`) return darrays and varrays instead of PHP arrays so they can convert to dicts and vecs in the Hack array migration.

Started by changing instances of `Array::Create()` to `Array::CreateDArray()`. Changed the function `force_to_output` to call `forceToDArray`. `forceToDArray` already exists, but I added a version that (I think) works with typed values.

Added tests (mostly slightly modified from existing tests, with `_2` appended to filenames) with the flag `HackArrDVArrs` on to check that DArrays and VArrays get converted to dicts and vecs properly.

Changed `forceToDArray` to call `forceToDict` when the `HackArrDVArrs` is on -- It turns out we need to do this explicitly.

Changed `add_offset_pair` to create a varray instead of a PHP array.

Reviewed By: ricklavoie

Differential Revision: D8742566

fbshipit-source-id: 67c930244cdac60e64fed667211939208c57f5ab
16 files changed:
hphp/runtime/base/preg.cpp
hphp/runtime/base/type-variant.h
hphp/test/slow/ext_preg/ext_preg_2.php [new file with mode: 0644]
hphp/test/slow/ext_preg/ext_preg_2.php.expectf [new file with mode: 0644]
hphp/test/slow/ext_preg/ext_preg_2.php.hphp_opts [new file with mode: 0644]
hphp/test/slow/ext_preg/ext_preg_2.php.opts [new file with mode: 0644]
hphp/test/slow/ext_preg/preg_match_impl_type.php [new file with mode: 0644]
hphp/test/slow/ext_preg/preg_match_impl_type.php.expectf [new file with mode: 0644]
hphp/test/slow/ext_preg/preg_match_impl_type_2.php [new file with mode: 0644]
hphp/test/slow/ext_preg/preg_match_impl_type_2.php.expectf [new file with mode: 0644]
hphp/test/slow/ext_preg/preg_match_impl_type_2.php.hphp_opts [new file with mode: 0644]
hphp/test/slow/ext_preg/preg_match_impl_type_2.php.opts [new file with mode: 0644]
hphp/test/slow/ext_preg/preg_match_literal_2.php [new file with mode: 0644]
hphp/test/slow/ext_preg/preg_match_literal_2.php.expectf [new file with mode: 0644]
hphp/test/slow/ext_preg/preg_match_literal_2.php.hphp_opts [new file with mode: 0644]
hphp/test/slow/ext_preg/preg_match_literal_2.php.opts [new file with mode: 0644]