Fix return types for HNI functions

Using Type::Any for a return type meant that assigning the result
of a function to a variable had no effect on the type of that variable.
It needed to be Type::Variant. I would dig deeper and try to sort it out,
but hopefully we're just moving to hhbbc, and can drop it.

Reviewed By: @edwinsmith

Differential Revision: D1241620
Change method of running oss tests without jit

Adding it to the command line args put it in PHP_BINARY, which broke phpunit.

Given it's only used to disable the jit, remove the first arg from the function.

Reviewed By: @JoelMarcey

Differential Revision: D1242275
Increase JitPGOThreshold to 10

I was never happy with such a low threshold, but that's what made
perflab happiest at the time.  However, I've seen a couple of cases
where the profile-guided region selector was making a bad decision
because of limited profiling information, so I decided to try to
increase this again. I tried a few values, and 10 seems to show a
small improvement.

Reviewed By: @bertmaher

Differential Revision: D1241344
Fix a slew of bugs in the systemlibs

Reported in CodeError.js while I was working on D1241620

Reviewed By: @edwinsmith

Differential Revision: D1242050
Fix behavior of AttrDynamicInvoke on persistent functions

Solve it the way we do for fb_rename_function, although it
also seems fairly unfortunate that FuncEmitter::create has actual
logic in it instead of just deserializing data from the repo.

The problem was this: if you have a 'dynamic invoke' function (means
it can be used with fb_intercept and fb_rename_function) that is also
persistent, it would get allocated a persistent RDS handle.  After its
unit is merged, the information about how to define the func is
removed from the UnitMergeInfo in compactUnitMergeInfo, because we
expect it to be defined forever now.  Then if any thread uses
fb_rename_function on it, it will null out the persistent RDS handle.
Since it was AttrDynamicInvoke, calls to the function are compiled
with LdFuncCached, which checks if the RDS handle is null, and if so,
invokes autoload.  However, autoloading won't define the Func anymore
because it was removed from the unit merge info.

Reviewed By: @edwinsmith

Differential Revision: D1242770
Correctly support the cache File::m_buffer in UserFile::getc() and UserFile::seek()

This fixes `getimagesize()` when applied to user streams.
Closes #2140

Reviewed By: @fredemmott

Differential Revision: D1235554

Pulled By: @ptarjan
fix calling session_set_save_handler multiple times

Matches php5, brings slim back up to 100%

Reviewed By: @ptarjan

Differential Revision: D1242541
Partially implement PharFileInfo, implement Phar iterator behavior

Turns some composer test fatals into failures.

Reviewed By: @ptarjan

Differential Revision: D1239646
fix trait constructors

It looks like we implemented something that didn't end up in the final version. All tests were recorded from php5

Reviewed By: @elgenie

Differential Revision: D1227544
Make the gdb python tools Python 3 compatible

Fixes #2062
Closes #2119

Reviewed By: @markw65

Differential Revision: D1233593
Support auto_prepend_file and auto_append_file

Closes #2171

Reviewed By: @fredemmott

Differential Revision: D1238390

Pulled By: @ptarjan
EZC: Implement TSRM globals

* Implement TSRM globals properly, i.e. have different globals for
  different threads.
* Enable the ZTS macro. This is generally used by Zend extensions to
  know if they need to be thread-safe, so for HHVM best answer is yes,
  please do be thread-safe.
* Move ZendExtension to a separate header file, plus another for inline
  functions, to allow circular declarations. Having it in zend_modules.h
  didn't fit the recommended coding style in README.md.
* Implement functions in zend_virtual_cwd.cpp which are now used due to
  ZTS being defined. This is necessary to link the new version, and fixes
  some bugs due to HHVM's virtual CWD system not previously being used.
* Move zend_wrap_func() to the .cpp file so that TSRM.h can be included
  without giving duplicate macro definitions throughout the non-EZC
  codebase.
* Tested VCWD_REALPATH() by adding a wrapper ezc_realpath(), which has
  exactly the implementation of realpath() from PHP PHP. Copied in the
  realpath() tests, replacing realpath() with ezc_realpath().
* expand_filepath_with_mode() was naively copied from Zend and had a few
  problems with it. Reimplemented.

The major implementation difficulty is ensuring that the existing
macros can transmit relevant data to the implementation, and ensuring
that the extern macro does actually give access to the globals. I would
have liked to put each module's globals in its own __thread variable,
but there was no way to supply the name of it to the constructor's
caller. Obviously you can't take the address of a __thread variable in
the zend_module_entry static initializer.

The implementation here is quite close to the Zend implementation,
except with an HPHP::ThreadLocal used for underlying storage. TSRMLS_CC
etc. is used as it is in Zend ZTS mode, and should provide a slight
speedup over TLS, especially with dynamic linking.
Closes #2063

Reviewed By: @fredemmott

Differential Revision: D1240880

Pulled By: @ptarjan
EZC: fix bug in _zval_copy_ctor_func()

The type of the dest zval was copied from the source, but in the
KindOfStaticString case, the data of the dest zval is overwritten with a
plain string. This causes an assertion when the dest zval is used.

Enable the test which previously failed due to this bug.
Closes #2045

Reviewed By: @fredemmott

Differential Revision: D1240866

Pulled By: @ptarjan
Convert ext/mysql to HNI

Part of #1480

Also includes the commit in #2024

Closes facebook/hhvm#2027

https://github.com/facebook/hhvm/pull/2027

Reviewed By: @ptarjan

Differential Revision: D1220239

Pulled By: @fredemmott
Expand namespace "use" mappings even outside a namespace

The included test case would have its "use" dropped on the
floor since it applied outside of a namespace. Tweak the `elaborate_id`
function to always expand even outside a namespace, and remove a bunch
of special cases that tried to be too clever when outside a namespace.

Closes #2145

Reviewed By: @gabelevi

Differential Revision: D1240331
Be more restrictive about statements at toplevel in strict mode

We weren't checking for certain types of toplevel statements.
We also need to consume semicolons since occasionally people do `class C
{ ... };` which we should admit even in strict. Also we were failing to
consume the semicolon after typedefs.

Closes #2144

Reviewed By: @gabelevi

Differential Revision: D1239786
Private member visibility checking is super broken

Oy. This was really broken. www is going to need a little bit of
cleaning up too.

  * `parent::privateFun()` is not allowed
  * `static::privateFun()` is not allowed (children can override `privateFun`
    with a private function, leading to a runtime error
  * `TraitIUse::privateFun()` is not allowed (you need to do
    `self::privateFun()`)

Reviewed By: @jwatzman

Differential Revision: D1243231
Add control-flow arcs to RegionDesc

To support more general regions, it's necessary to specify which
control-flow arcs are within a region.  This diff adds basic support
for storing these arcs in the RegionDesc and changes the various
region selectors to store the arcs in the regions they produce.
Follow-up diffs will change the region translator to actually follow
what arcs are within the region.

Reviewed By: @bertmaher

Differential Revision: D1242572
Make HNI class constants visible to static analysis

They're not defined in the php code, so need to be
explicitly added to the ClassScope's ConstantTable.

Reviewed By: @edwinsmith

Differential Revision: D1242764