Make sort()/ksort() mirror php5 in EnableZendSorting mode

Summary: Fixes #3545

Reviewed By: @ptarjan

Differential Revision: D1512943
Fix File::readCSV for crlf line termination

Summary: When we see a "\r" at the end of the buffer when reading a line in File we should read ahead further to see if it's part of a "\r\n".

Fixes #1658

Reviewed By: @sgolemon

Differential Revision: D1656908

Signature: t1:1656908:1415080300:9e9e054f4986057d311f716f89a6bffa3ed8eef6
Allow duplicate items in encoded urls

Summary: Fixes #3878

Reviewed By: @sgolemon

Differential Revision: D1633028

Signature: t1:1633028:1414515060:c5eec7b2d50f67a81098a929b8c191d40eb87f96
Use int64_t when scanning integers, not int.

Summary: sizeof(int) == 4 means that we'll have overflow on large integers

Closes #3449

Reviewed By: @paulbiss

Differential Revision: D1657453

Signature: t1:1657453:1415121399:a71cf3326274f29caf3b825e7413bea332661cfd
Fixed xpath's php:functionString

Summary: Added CallerFrame before dom_xpath_ext_function_php's call to xmlXPathEvalExpression in case libxml2 needs to call back into HHVM.
The xpath query might contain ```php:functionString``` which triggers a call to any arbitrary php function.

Also fixed a bug where the arguments in an xpath php:functionString were reversed. For example, if the xpath was ```/foo[php:functionString('preg_match', '{$regex}',@​bar)]```, preg_match was being called as ```preg_match($bar, $regex)``` instead of ```preg_match($regex, $bar)```.

Closes https://github.com/facebook/hhvm/pull/4120

Reviewed By: @sgolemon

Differential Revision: D1656106

Signature: t1:1656106:1415132682:3423279074575c41ba3f39136ab2abd3f29ae232
Invert how hh_server gets hhi embeds

Summary: Change some FB-internal build scripts, and add a comment.

Reviewed By: @int3

Differential Revision: D1658042

Signature: t1:1658042:1415126267:110682c52c6711465a9634c6a121adb3d38c285f
Use timelib_diff to calculate datetime intervals

Summary: Fixes #2952

Reviewed By: @JoelMarcey

Differential Revision: D1657306

Signature: t1:1657306:1415077618:3781defe888af49033d1743a7d50aa48612141a0
Convert a few ARM opcodes to DELEGATE

Summary: This is just a few of the easiest ones, to get started with. It helped
to flush out a few issues:

- x64's implementation of DefSP was referring to rbp explicitly, instead
  of the tmp representing the frame pointer.

- ARM was defining a status flag register twice; this looks like a rough
  edge of the conversion to explicit status flags.

Reviewed By: @edwinsmith

Differential Revision: D1658070
Deep initialization for constant properties

Summary: Defined constants may be ref-counted (e.g. resources) and require deep
initialization when used to initialize instance properties.

Fixes #4111

Reviewed By: @fredemmott

Differential Revision: D1658088

Signature: t1:1658088:1415137574:011205e3e604bb711437149f2ef1ed3b3be830b5
Initial sort should be density based

Summary: The initial order of functions influences the final
clustering - so we should use samples/byte, not samples to
sort them.

Reviewed By: @ottoni

Differential Revision: D1657737

Signature: t1:1657737:1415119241:e145694681f86a14ae63a23f73a2011e1dfd6347
Add HH\int/float/bool typehints to PHP

Summary: - Support HH\(string|int|float|bool) in PHP without hhvm.force_hh
- (string|int|float|bool) in PHP without in hhvm.force_hh still refer to classes

These are not intended for direct usage by developers.

Mocking frameworks find the parameter typehints using reflection, then generate
mocks in PHP using the same typehint. 3 ways to fix this came to mind:

 - Always support HH\foo scalar typehints
 - Modify Reflection to not return these
 - Modify these mocking frameworks to filter out scalar typehints

This diff takes the first option.

fixes facebook/hhvm#4021

Reviewed By: @paroski

Differential Revision: D1642075

Signature: t1:1642075:1414634502:1901bd88b334adfa9b0b39925d706675892f6411
Allow systemlib function declarations to use reserved words for function names

Summary: This allows builtin classes to define methods like "include" or "declare".
Necessary for replicating PHP5 extension interfaces in HNI.

  class Foo {
    public function include(string $file): bool {
      include($file);
      return true;
    }
  }

  (new Foo)->include("/bar/baz.php");

Closes #2022

Reviewed By: @paulbiss

Differential Revision: D1658153

Signature: t1:1658153:1415127992:e16e66ff2b5f6bef37e56be7e58d9a0fe86af4d3
Remove uspoof SINGLE_SCRIPT test.

Summary: It's deprecated on ICU >= 51

Closes #3925

Reviewed By: @JoelMarcey

Differential Revision: D1658533

Signature: t1:1658533:1415134838:c7bd38f7fdfed37acbcee497da7e7aed94d16850
Explicitly set -Wno-unused-function in gcc flags

Summary: This should be the default, but for systems
where it isn't, explicitly say so.

Closes #2515

Reviewed By: @JoelMarcey

Differential Revision: D1658664

Signature: t1:1658664:1415134757:d4d26bec54469d0bee379d4134c4d3c3e98b3dd1
Suppress compilation error by undefining basename macro

Summary: Closes https://github.com/facebook/hhvm/pull/4132

Reviewed By: @sgolemon

Differential Revision: D1658567

Signature: t1:1658567:1415147482:2d83b43e9b00743f939bf36f4377114bdd2568a7
Update .noserver files for in-memory sqlite dbs

Summary: The ':memory:' sqlite3 file can cause conflicts when multiple tests
run in the same server process.

Reviewed By: @jdelong

Differential Revision: D1659326

Signature: t1:1659326:1415144962:8b10e2c405b8cb3cd047d2249d561e68c2079314
Fix DOMDocument::createElement{,NS}

Summary: Use registered class to create new elements.

Fixes #2962

Reviewed By: @sgolemon

Differential Revision: D1657409

Signature: t1:1657409:1415147180:2a159c68faf214dc7fb21f94a956c14400cc17b4
Use smart_malloc for Resumable objects so we can parse the heap.

Summary: Trying the simple approach. If this increases memory usage
too much, it might be possible to rearrange things and make
a new Resumable kind that we can parse w/out extra overhead.

Reviewed By: @jano

Differential Revision: D1658158
Use smart_malloc for AwaitAllWaitHandle

Summary: Need a parseable header that reflects the object's true
size, or a dedicated Kind so we know how to parse it. Trying
the simple approach first. This class is also going to need
a custom scanner because of the embedded objects it holds.

Reviewed By: @mclarkelauer

Differential Revision: D1658087
Convert easy arithmetic ops to DELEGATE

Summary: My plan for now is to convert everything I can that's explicitly
implemented in code-gen-arm.cpp before tackling the long list of punting
opcodes.

Another few issues here, most notably `imul`. I think emitting `imul` as
`Mul` on ARM is wrong, because I realized we're actually counting on it
to set condition flags, and there's no multiply instruction on ARM that
will do that. I split it into another vasm opcode to make this clear.

It'd be nice to use non-flags-setting ARM opcodes when they're not
needed; I guess this can be done in a later pass (after DCE determines
that the flags aren't used).

Reviewed By: @edwinsmith

Differential Revision: D1658861