Only ignore hashbang line in cli mode

Summary: @​see https://github.com/php/php-src/blob/master/sapi/cli/php_cli.c#L606
Closes https://github.com/facebook/hhvm/pull/4183

Reviewed By: @JoelMarcey

Differential Revision: D1669155

Signature: t1:1669155:1415548679:cbc90bcbd8331cd54018590dab2747f7d6a28813
Improve fix for issue #4111

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

Reviewed By: @JoelMarcey

Differential Revision: D1669151

Signature: t1:1669151:1415548684:b89950d6e0f02fa8a4fc4bc0a9b17d4fb5835a07
issue,4156: xml skip white option also skips new lines'\n' charachters a...

Summary: ...s well,By avoiding this php and hhvm now behave the same.
Closes https://github.com/facebook/hhvm/pull/4185

Reviewed By: @JoelMarcey

Differential Revision: D1669156

Signature: t1:1669156:1415548942:aee891116a06f9eedc66c65ca4491785b3e0c443
Fix fribidi dependency includes

Summary: Fribidi depends on glib, but we're not adding the header file include dirs into our paths.  This makes cmake find glib for us.  Without this, the build fails to find glib.h (on gentoo) and halts.
Closes https://github.com/facebook/hhvm/pull/4187

Reviewed By: @JoelMarcey

Differential Revision: D1669177

Signature: t1:1669177:1415549048:7bff25565005cd0ec28326c41e48f561f5061775
GetPrimaryIP is IPv4 only

Summary: GetPrimaryIP uses gethostbyname which is IPv4 only.  Now we cache
both the IPv4 and IPv6 address of the host so SERVER_ADDR can be set based
on the request being made.  Without this change, $_SERVER['SERVER_ADDR']
on IPv6 only hosts would return the hostname instead of an ipaddress
for xbox-server and libevent-server.  Unfortunately with libevent-server,
access to the remote client fd would allow getting the server's
address, but it is not, so use this hack for now.

Also, retire safe_inet_ntoa in favor of folly:IPAddress

Reviewed By: @bmatheny

Differential Revision: D1658651

Signature: t1:1658651:1415566504:ab034dbef2e19613b4d1fc14899c4df852158e96
Don't leak HashContexts

Summary: HashContext is allocated via the global operator new,
and it contains a std::shared_ptr, so we need the default
sweep behavior, which is "delete this".

Reviewed By: @bertmaher

Differential Revision: D1668713

Signature: t1:1668713:1415417867:13da80e72cce887104b547e737fbbd37fcbd52cc
Initial support for "$obj->:xhp-attr" syntax

Summary: This diff adds initial support for "$obj->:xhp-attr" syntax. As a first
step, this syntax will desugar to "$obj->getAttribute('xhp-attr')" to
support using the new "$obj->:xhp-attr" syntax to read attributes from XHP
objects.

Future plans include supporting "$obj->:xhp-attr" syntax for writing to
attributes on XHP objects and incorporating XHP attributes more with the
core runtime (ex. storing attributes inline inside the object similar to
normal object properties), but this will come later.

Reviewed By: @elgenie

Differential Revision: D1641268
Fix bug with "list($this) = .."

Summary: In some cases, trying to assign to "$this" via list assignemnt can cause
HHVM's bytecode emitter to encounter errors. This diff fixes the bytecode
emitter errors and makes HHVM match PHP5's behavior.

Reviewed By: @elgenie

Differential Revision: D1667214

Signature: t1:1667214:1415391466:d4ca1852a2ddc3ac560949d049f27c8c55c40b83
Remove unnecessary wrapper functions from ext_collections

Summary: Now that HHVM doesn't use the mangle map scheme for extensions defined in
.idl.json files, we can eliminate a bunch of unnecessary wrapper functions
in ext_collections.

Reviewed By: @jdelong

Differential Revision: D1665279

Signature: t1:1665279:1415492122:752981f56cace95bed4163612ca6710bf1fded46
Don't use Sweepable for APCLocalArray

Summary: Keep track of APCLocalArrays using a dedicated list in MemoryManager,
similar to how we track APC strings. This makes APCLocalArray not
use Sweepable, which devirtualizes it and reduces sizeof from 64 to 40.

Reviewed By: @jdelong

Differential Revision: D1669231

Signature: t1:1669231:1415548069:e617e85f2866d031f9dc313ccc69420d3d19f3ba
Add thread type and pagelets started functions

Summary: Caveat: I have close to no idea what I'm doing here. Don't
hesitate to tell me if everything is wrong, ugly, or will explode.

Add some very basic instrumentation around pagelet requests.
Currently we don't have any idea how many pagelets a request starts or
(AFAICT) a way to tell whether a request is a pagelet, besides looking
for PHP implementation details like parts of the request query string.

1) ##hphp_thread_type()## -- what kind of thread is this request running
in? Returns an int from ##enum class ThreadType## or -1 if we can't work
it out. There is an existing function (##getThreadTypeName()##,
https://fburl.com/65216334) but this returns strings with spaces, which
are a pain for dyno logs.

2) ##pagelet_server_tasks_started()## -- return the count of pagelets
started in this request. I didn't do this in PHP as there are already
two places in which we start pagelets (GraphBatchAsyncWorkItem and
PageletServerFuture) and two places in HHVM to start pagelets
(pagelet_server_task_start and fb_gen_pagelet). Instrumenting the server
is easier than making sure all the callsites in PHP track this.

I added both of these as functions and not access log parameters so we
can easily add them to xenon and other profilers.

Reviewed By: @bertmaher

Differential Revision: D1667021
Add pcntl_sigprocmask

Summary: fixes facebook/hhvm#4160

pthread_sigprocmask seems most correct given HHVM's model, however for both PHP-FastCGI and HHVM, the mask will leak cross-request

Reviewed By: @paulbiss

Differential Revision: D1667740

Signature: t1:1667740:1415399505:d7edad8e22ba9c8063800c98adf284ffe886f360
Use Func::destroy to clean up elements of the pseudomain cache

Summary: Funcs in the pseudomain cache are allocated by clone -- it seems like
they should be deallocated by destroy, rather than just deleted.  (ASAN
complains about the mismatch between malloc'ing the Func and deleting it.)

Reviewed By: @markw65

Differential Revision: D1668805

Signature: t1:1668805:1415417063:efd7495176f15d82660cd10037d5a0d54b52588c
Embed HNI in runtime_test

Summary: runtime_test currently only contains systemlib. We need to also include all the HNI extensions. This is blocking DateTime + collection HNI conversion.

Reviewed By: @sgolemon

Differential Revision: D1668323
get_defined_functions are all lowercase

Summary: Increases symfony from 98.68 to 98.82
Closes https://github.com/facebook/hhvm/pull/4192

Reviewed By: @JoelMarcey

Differential Revision: D1669234

Signature: t1:1669234:1415643321:87e1629b58ab39076cfd1d316bca152466b3dcf0
change is_object() to gettype() === 'object' in spl for incomplete_class

Summary: PHP accepts __php_incompatible_class in spl. But objects from that class fail is_object.

This puts symfony from 98.68 to 98.8 percent.

I don't like to do this...
Can we run perf on this? I don't know how bad it is.

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

Reviewed By: @JoelMarcey

Differential Revision: D1669230

Signature: t1:1669230:1415643326:4fdf2dd7aae73ae07abd66bb0efa2becb2d22e75
Bump package_version

Summary: Set to 3.5 on the master branch
Closes https://github.com/facebook/hhvm/pull/4178

Reviewed By: @JoelMarcey

Differential Revision: D1669146

Signature: t1:1669146:1415649436:23c7e004b34cc525b29d9897834de48bc43a0eb7
Convert ext/spl to HNI

Fixes #3947
This was a missing clone in the assignment.
null_variant => null; only clone on objects
Move some implementations back to php

And add test for #3947