Error messages related to magic methods

Summary: This diff implements many small error messages thrown around magic methods.

Reviewed By: @ptarjan

Differential Revision: D1423455
Fix autoloading for "type" and "newtype" statements

Summary: If the name on the right hand side of a "type" or "newtype" statement does
not name an existing class/interface/trait or an existing type alias, HHVM
tries both class-autoloading and type-autoloading. The problem is that if
class-autoloading doesn't find anything, HHVM calls the failure callback
before trying type-autoloading, which can cause problems for correct
programs (see the test cases).

This diff fixes HHVM to try both class-autoloading and type-autoloading
before calling the failure callback for "type" and "newtype" statements.

Reviewed By: @elgenie

Differential Revision: D1410570
typechecker: keep track of type params for require extends X<T1, T2, ...>

Summary: ... these were previously being thrown away and replaced with the
 type params of the containing trait and interface, usually working
 simply because the typechecker is (too) tolerant of classes without
 bound type params. The code for this is somewhat involved and
 complicated by the fact that a `require extends Foo<T1, T2>` requires
 the type variables `T1` and `T2` to be substituted juuuuust right in
 each place they're used.

Reviewed By: @jwatzman

Differential Revision: D1410558
add spaces to readme

Summary: Closes #3156
Created from: https://github.com/facebook/hhvm/pull/3156

Reviewed By: @fredemmott

Differential Revision: D1427582
Use timeout from GNU coreutils instead of bash hack

Summary: When using timeout.sh to run tests, test execution hangs until the
"sleep 1" finishes, probably because the monitor process keeps
filehandles open. If you instead use timeout from GNU coreutils, test
execution is about 2.5 times faster -- I measured a drop from 75 to 30
seconds for test/quick.
Closes #3021

Reviewed By: @LiraNuna

Differential Revision: D1427372

Pulled By: @fredemmott
Remove CallHelperInfo (dead code)

Summary: We don't need the return value from cgCallHelper anymore.

Reviewed By: @jasone

Differential Revision: D1426737
libdwarf, libpam, libelf, bootstrap cmake fixes

Summary: First: libdwarf. libdwarf seems to have no problem making breaking
changes and provides no easy way to even test the version you're
building against. I have added two tests in `FindLibDwarf.cmake` to
detect a change to function type signature and to detect the removal
of `dwarf_producer_init_c`. Hopefully this will work on all systems.

The recent change to use more system libraries broke the build of the
`gen-*` bootstrap utilities, as the targets were not updated to use
the system `double-conversion` library and instead attempted to use
the (unbuilt) local one.

Commit 83cbca11c1 made linking to libpam happen only on OSX. This
breaks the build on ArchLinux and openSUSE at least. I reverted this
change given that detecting whether or not you need to link to it is
quite difficult.
Closes #3134

Reviewed By: @ptarjan

Differential Revision: D1427288

Pulled By: @fredemmott
Don't over-consume local values when inlining

Summary: FrameState::forEachLocal includes locals from inlined callers. This is
what we want when we're consuming all locals to leave a trace, but not when
we're processing an instruction that just consumes locals from the current
frame.

Reviewed By: @jdelong

Differential Revision: D1426975
Clean up JIT handling of nop bytecodes

Summary: - Turn (Un)BoxR(Nop) into regular instructions. The assertTypeStack calls
  aren't needed since the next instruction will assert the same types anyway.
- Remove NormalizedInstruction::noOp since it's no longer needed.
- Rename NopDefCls to DefClsNop to be consistent with the other Nop bytecodes.

Reviewed By: @jdelong

Differential Revision: D1426804
Don't save a block's FrameState in FrameState::update

Summary: It's already saved in IRBuilder::finishBlock, so this was redundant.

Reviewed By: @bertmaher

Differential Revision: D1425693
Adjust the encoding m_pos uses when pointing past the last element

Summary: This diff changes the way arrays encode m_pos when it points past the last
element. Before, ArrayData::invalid_index (-1) was used. This diff changes
it to uses a non-negative value that is greater than the position of the
last element (if there is a last element). This allows PackedArrays and
MixedArrays to set m_pos to 0 initially, and then they never need to update
m_pos when a new element is added.

Reviewed By: @edwinsmith

Differential Revision: D1384311
Create abstraction for things that can block on WaitHandles

Summary: Create abstraction for dependency graph that can include nodes that are
not WaitHandles. Introduce the following data structures:

- AsioBlockableChain, a structure to be embedded in the child, stores
  head of the linked list of parents
- AsioBlockable, a structure to be embedded in the parent, stores
  pointer to the next node in the linked list

This will be used by AsyncPoll, which will embed multiple AsioBlockables
(one per each dependency to be polled).

Reviewed By: @billf

Differential Revision: D1425998
Always save the state for the current block before switching to new one

Summary: In a diff I'm working on, I was hitting an assert in ##IRBuilder::insertLocalPhis## because the FrameState for a block hadn't been saved. Inspecting the code, I found this place where the FrameState for a block wasn't being saved before switching to another block.

Reviewed By: @bertmaher

Differential Revision: D1425862
set PHP_VERSION to 5.6

Summary: Now that @elgenie landed splats and variadics, we are feature complete with 5.6.
Closes #3003

Reviewed By: joelm, smith, eletuchy, liranuna

Differential Revision: D1426390
get us compiling on travis

Summary: They are using an older version of libsqlite3, which our make files don't reject, but we end up not compiling. This is the easiest fix.

Reviewed By: @JoelMarcey

Differential Revision: D1428652
Fix boundary cases of strspn, strcspn and substr_replace

Summary: I'm all for refactoring, but a precondition for refactoring is that the original copies of the code in some way resemble each other. While the bounds checks for strspn, substr_replace and substr might look superficially similar, in fact they can't be merged with a single simple if(strict) to take care of the divergence. The main problem is that multi-pass normalization of the inputs gives you some interesting and arguably broken behaviour when there are multiple issues that need to be simultaneously fixed.

So, unrefactor (expand?) string_substr_check() into its three consistutent parts, with code in the two new parts based closely on the Zend source in the current git master. Remove the "strict" parameter, now implicitly true.

Added a test case which previously failed in multiple ways. In particular, strspn('','x') returned the wrong thing, which broke the MediaWiki parser quite badly. The expect file was generated by PHP 5.5 and is identical to the one generated by PHP 5.3.

Closes #2987

Reviewed By: @ptarjan

Differential Revision: D1393755

Pulled By: @fredemmott
Add MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH logic to store_result

Summary: This is the same as #3016 but moves the implementation to PHP instead.

It actually does not fix the bug itself because PHP behaves the same.
The cause of the segfault is that some people run out of memory resulting in a bad call to calloc.
calloc returns a nullptr which later in mysql is dereferenced.

PHP's solution to this is to call store_result before binding. But this will also fail in hhvm.
This fixes it.

Thanks SiebelsTim for writing the original diff in C++

TL;DR: TEXT in mysql is now variable length instead of 4GB when calling store_result

Fixes #2377
Fixes #2921

Reviewed By: @JoelMarcey

Differential Revision: D1407344
Cleanup in Translator

Summary: I did this while moving inlining into translateRegion().  No change in
functionality; just documentation, reorganization, eliminating dead
functions, etc.

The inlining change requires splitting up translateRegion() a bit, so I
haven't touched translator.cpp.  I also didn't touch translator.h below
the definition of Translator, but I'll probably deal with that later.

Reviewed By: @swtaarrs

Differential Revision: D1427960
bug fix in naming declaration

Summary: During a name collision (on a global symbol, like a class), the name of the
symbol should be bound to the first version of the definition (the one that was
previously there), not the new one (the one that created the collision).
Otherwise it will break the incremental mode.
The incremental logic does the following:
1) remove everything we knew about the declaration
2) redeclare

If after a collision we bind a class name to the new class it will remove
the declaration of the new class (the wrong one) and break.
This bug was likely introduced by the series of diff updating the type-checker
to not stop at the first error.
We use to throw on a naming error and because of that the naming environment was naturally bound
to the first version of the definition.

Reviewed By: @jwatzman

Differential Revision: D1428722
Add basic support for Toran proxy

Summary: Experimenting. We're not using this yet. Removes the dependency on packagist.org. Removes github dependency for stuff installed via packagist, but not for explicit dependencies in the JSON.

Reviewed By: @ptarjan

Differential Revision: D1425023