Add a control-flow test with a loop and multiple translations for a srckey

Summary: This test exercises some corner cases that were causing assertion
failures in dbgo (now fixed).  It never quite repro'ed the exact bug I was
seeing, but it seems like a reasonable stress test to have in the tree.

Reviewed By: @alexmalyshev

Differential Revision: D1403027
Log unit when failing the fromLoad assertion in refcount opts

Summary: This assert popped up on a diff last night but it seems somewhat rare,
so let's print the unit to debug it when it does happen.

Reviewed By: @ottoni

Differential Revision: D1402862
Fixing out of tree build, cmake

Summary: Closes #3023
Fixes #2922

Reviewed By: @ptarjan

Differential Revision: D1400227

Pulled By: @JoelMarcey
`hh_server --check` use the right error code

Summary: This has annoyed a lot of folks, let's fix. We `exit 0` on no
errors, `exit 1` on errors.

Reviewed By: @fredemmott

Differential Revision: D1403902
Fix reuse of dead persistent sockets

Summary: This fixes a bug where dead persistent sockets could be re-used
because the return value of the recv() syscall wasn't properly
checked. Previously, if recv returned -1 to signal an error
without setting errno to EAGAIN, the socket was erroneously
reused. This brings the persistent socket reuse check to
parity with Zend.

Also removed an outdated comment.
Closes #3004

Reviewed By: @ptarjan

Differential Revision: D1398661

Pulled By: @JoelMarcey
check for fun('Foo::bar')

Summary: Pretty much anything can happen inside a string. We might
 want a check for "valid function name", but the most common error,
 using fun on a class method, deserves its own error, because it works
 in the runtime with ##call_user_func##, but not with direct
 invocation using ##$f()##.

Reviewed By: @jwatzman

Differential Revision: D1400880
better targeting of parent::__construct onto traits

Summary: ... looking at ##req_extends## when calculating the parent
 constructors that need to be called is excessive for the required
 check that a trait with a ##__construct## indeed calls its parent (since
 there's no ##parent::__construct## that can access a trait's constructor).

Reviewed By: @jwatzman

Differential Revision: D1401948
modify builtin_functions.hhi with additional annotations

Reviewed By: @jwatzman

Differential Revision: D1397403
Small doc fix for ResourceData vs. SweepableResourceData

Summary: Closes #3031

Reviewed By: @ptarjan

Differential Revision: D1402926

Pulled By: @JoelMarcey
wddx_deserialize() systemlib improvements

Summary: * Use stream_get_contents() instead of a loop of fgets(). Loops that read files are deceptively tricky -- it's possible to hit an error in which fgets() permanently returns false but with feof() being false, for example NFS server failure, which would cause an infinite busy loop with the previous code.
* Do not accept SimpleXMLElement objects as input -- this was a hack to allow recursive parsing without creating another global function. Achieve the same ends using a closure instead.
* Do not attempt to call $packet->getName() on any input that is not a string or resource. Instead mimic Zend and give a warning.
* Check for errors from simplexml_load_string(), instead of giving a fatal error due to calling false->xpath().
* Ignore malformed input in various cases, skipping array members etc., instead of assuming the XML is always perfect and inevitably hitting a fatal error due to invalid method calls. This is somewhat similar to what Zend does -- probably not identical though.
* Added a test case for malformed input based on the motivating unit test from MediaWiki.

Applied formatting patch from: http://noc.wikimedia.org/~ori/pr2991-fixups.patch

Closes #2991

Reviewed By: @ptarjan

Differential Revision: D1397192

Pulled By: @JoelMarcey
DirectoryIterator throws RuntimeException on empty string

Summary: Fixes zend/bad/ext/spl/tests/DirectoryIterator_empty_constructor.php but I can't move it because of the different representation of uncaught exceptions

The included test is a duplicate of the one above, but with a try-catch block
Closes #3001

Reviewed By: @ptarjan

Differential Revision: D1396928

Pulled By: @JoelMarcey
Make test runner do a better diff

Summary: While working on some tests, I noticed the php5 test runner (which ours is based heavily on) has a much nicer failure-diff than we do. So I took it.

Reviewed By: @JoelMarcey

Differential Revision: D1402452
Assume code execution cannot continue after PARSE_ERROR()

Summary: PARSE_ERROR() is a simple macro that throws exception. The next line of
code is thus unreachable. Remove dead code, in some cases function
return values and related checks.

Reviewed By: @mxw

Differential Revision: D1404328
Implement mysqli::$error_list

Summary: Fixes #2861

Reviewed By: @WizKid

Differential Revision: D1400138
return null from invariant when optimized away

Summary: The original function doesn't return anything, so when we optimize it, it should stay true to that.

Reviewed By: @markw65

Differential Revision: D1403616
allow test files to have spaces

Summary: I'm fixing rex's tests, and his directory had  spaces in it

Reviewed By: @JoelMarcey

Differential Revision: D1399781
Fix typechecking the hhi files

Summary: Fixes facebook/hhvm#3036

Sed.

Reviewed By: @JoelMarcey

Differential Revision: D1403524
Refactor cell and type arith for shift operators

Summary: They were just handwritten in several areas, this finally adds
{cell,type}Sh{l,r} to match the other functions.

Also changes the returns on some of the type-arith functions from
TInitCell in the worst case to TInitPrim.

Reviewed By: @jdelong

Differential Revision: D1380563
Fixed error output for json_encode

Summary: `json_encode` threw a notice instead of setting a json error, this caused several discrepencies including forgotten implementaion of `JSON_PARTIAL_OUTPUT_ON_ERROR`.

Reviewed By: fredemmott, ptarjan

Differential Revision: D1393135
Handle DefLabel in constrainValue

Reviewed By: @swtaarrs

Differential Revision: D1399894