Implement wordwrap() natively

Reviewed By: @ptarjan

Differential Revision: D1440874
Fix Redis::sRandMember()

Summary: Don't require a second parameter which is originally optional.
Also, it shouldn't always return an array.

Closes: #3213
Closes #3217
Created from: https://github.com/facebook/hhvm/pull/3217

Reviewed By: @swtaarrs

Differential Revision: D1442294
For future safety: "-1" is dangerous when comparing with unsigned type.

Summary: For future safety: "-1" is dangerous when comparing with unsigned
type.

Reviewed By: dmitrip

Differential Revision: D1442895
cotire 1.6.4

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

Reviewed By: @ptarjan

Differential Revision: D1435738
unset another cached variable for dwarf detection

Summary: We're not actually broken right now because of the way we fall-back to
dwarf_producer_init_c, but a function exists check is still being
skipped due to CMake caching. That could potentially confuse things
if/when another init function were to be added in the future.
Closes #3200
Created from: https://github.com/facebook/hhvm/pull/3200

Reviewed By: @ptarjan

Differential Revision: D1438631
Fix CMake to install hh_client and hh_server

Summary: Make sure we install under bin/ the hack binaries.
Closes #3192
Closes #3158
Created from: https://github.com/facebook/hhvm/pull/3192

Reviewed By: @jwatzman

Differential Revision: D1435736
Reorganize and refactor Unit

Summary: This is partway towards having less monolithic and more documented Unit
code.  The rest of the cleanup is imminent, but it was starting to get
out of control in scope and I wanted to get this much in first to avoid
conflicts.

Notable changes include:

- Clean up and document all of Unit's methods.  Also do some easy
  refactoring, delete some undefined functions, and privatize some
  things that aren't used publicly.

- Kill Unit::m_cache{Offset,Mask}, which were always zero and never
  mutated.

- Refactor the code copypasta'd between LitstrTable and Unit into
  NamedEntityPairTable, and move the global NamedEntityMap into
  named-entity.h.  This untangles the dependency between LitstrTable and
  Unit and also slays villainous duplication.

- Remove the m_litstrs vector of StringData*'s from LitstrTable; it is
  redundant with the first component of m_namedInfo, the vector of NEPs.
  This is the only real functionality change included in this diff.

- Move UnitEmitter and UnitRepoProxy to unit-emitter.h---though we're
  currently relying on unit.h for all our includes.  This will be fixed.

Reviewed By: @alexmalyshev

Differential Revision: D1440780
In mysql_escape_string() use ReserveString instead of AttachString

Summary: * Use ReserveString instead of AttachString in mysql_escape_string()
  and mysql_real_escape_string(). AttachString should really be
  deprecated, since it doesn't actually attach, it just copies.
* Don't truncate the return value of the underlying C API call -- use
  unsigned long.
* Upgrade string size to size_t before doing arithmetic. Overflow is
  probably not possible in this case, but it's a good habit to get into.
* Added missing skipif.inc from PHP, so that the relevant tests would
  run.

Submitted on behalf of a third-party: The PHP Group
Source: PHP 5.7.0-dev
License: version 3.01 of the PHP license
Closes #3198
Created from: https://github.com/facebook/hhvm/pull/3198

Reviewed By: @ptarjan

Differential Revision: D1438627
freetype 2.16+

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

Reviewed By: @ptarjan

Differential Revision: D1438014
RBTrace should be NNT

Summary: I missed this when making CallsNative imply MayRaiseError.

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

Reviewed By: @bertmaher

Differential Revision: D1442287
target 3.3

Summary: 3.2 is out

Reviewed By: @JoelMarcey

Differential Revision: D1443788
Add an opt_map function to Utils and change a bunch of code to use it

Summary: Add a function for ordinary mapping over options to Utils and replace the option maps that I found with it.

I looked for option maps with: grep -r -- 'Some [a-z]* -> Some'

Reviewed By: @elgenie

Differential Revision: D1442431
Improve error messages through instantiation

Summary: During generic instantiation, we'd drop part of the position
information on the floor. This information can be quite useful, to be
lead through a potentially long path of generic instantiations to the
place that things actually ended up incompatible. This diff tracks the
location of all those instantiations and prints them as part of the
error message. In some cases, this can lead to a somewhat longer error
message, but it's IMO worth it to have the added information -- in some
pathological situations, there would way too little error info. More
error info is always better, right?

This came up when trying to work on async generators, since I think I
want to make `Continuation` a type alias for `Generator`, and
incompatibilities are painful to read without this information (see unit
test).

Reviewed By: @elgenie

Differential Revision: D1439540
A few small hhbbc tweaks

Summary: - reduce BoxR to BoxRNop
   - constprop CGetS
   - reduce InstanceOf to InstanceOfD in one more case
   - allow dce to remove AGetC

Reviewed By: @elgenie

Differential Revision: D1415312
Always mark Closure classes as NoOverride

Summary: Closures cannot be extended, so we can mark them as NoOverride even in
non-repo modes.

Reviewed By: @jdelong

Differential Revision: D1442144
Remove XMLWriter test temporarily

Summary: Seems relatively harmless, likely cauesd by HNI conversion. Will investigate reverting this immediately.

```
[fredemmottdevbig076 ~/fbcode/hphp/test] php5 quick/builtin_extension_XMLWriter.php | grep -i startattributens
  string(16) "startAttributeNs"
  string(16) "startAttributeNs"
[fredemmottdevbig076 ~/fbcode/hphp/test] hhvm quick/builtin_extension_XMLWriter.php | grep -i startattributens
  string(16) "startAttributens"
  string(16) "startAttributens"
```

Reviewed By: bsimmers, ptarjan

Differential Revision: D1444383
clean up libxml/dom/simplexml

Summary: - Move 2 php_libxml_* functions to their appropriate place to
  reflect Zend (libxml extension).
- Call these functions from SimpleXML to properly clean up after
  ourselves, which earlier was incorrect assumed to be entirely
  handled by xmlFreeDoc in sweeps.
- Don't NULL out node->doc, this should only be done at refcount 0 to
  prevent double frees. XML extensions take care of this themselves.

There's still a bunch of work needed to be done: SimpleXML and
DOMDocument share a lot more functionality that should eventually be
moved to libxml as well.

That will be a gradual process however, and this change plugs a leak in
the meantime.

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

Reviewed By: @ptarjan

Differential Revision: D1443782
Implement shapes with class constant fields.

Summary: Add support for using class constants as field names in shapes to Hack. Shapes must either use all class constants or all strings. Class constants can either be ints or strings, but must all be the same. This doesn't include extending HHVM to support them.

Reviewed By: jwatzman, eletuchy

Differential Revision: D1377943
Readd xmlwriter quick test

Summary: Was only failing on my machine due to a local build issue. Doesn't seem to be a problem on sandcastle, or on mine after a clean build

Reviewed By: @ptarjan

Differential Revision: D1444452
Hack: fix inconsistency where hh_client takes file name instead of content

Summary: Only two that take file name are: `--color`, `--type-at-pos`. On the other hand `--auto-complete` and `--outline` take stdin.

Reviewed By: @joelbeales

Differential Revision: D1444286