Add PhutilAggregateException

Summary: See T1021, add a specialized exception for handling cases like the example provided.

Test Plan: See next diff.

Reviewers: btrahan, vrana, jungejason

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1021

Differential Revision: https://secure.phabricator.com/D2156
Add functions for grabbing the first and last keys from an array.

Summary:
head_key($array);
and
last_key($array);

Test Plan:
```<?php
$arr = array('Herp'=>1,'Derp',2);
echo head_key($arr);
echo last_key($arr);
```

Reviewers: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D2161
minor, added unit_test, and type hinting
Fix typo in comment

Auditors: epriestley
Merge pull request #11 from Koolvin/quick_functions

Add functions for grabbing the first and last keys from an array.
Fix external [[ ]] Remarkup links

Summary: Broken by D2110 and D2111.

Test Plan:
Disable `differential.custom-remarkup-rules` which tricked my original test plan.

  [[ http://example.com | test ]]

Reviewers: Koolvin, epriestley

Reviewed By: epriestley

CC: aran, epriestley

Maniphest Tasks: T1090

Differential Revision: https://secure.phabricator.com/D2164
Link to Phabricator instead of GitHub in generated docs

Test Plan:
  diviner .

Click on source link.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D2185
Improve SSL error message for CURLE_COULDNT_RESOLVE_HOST

Summary:
This message doesn't narrow things down much, but provide a friendlier version of it.

Theoretically we could do an "are you connected to the internet?" test by getting a plurality vote on connectivity to several major web properties or something, but that seemed maybe-excessive?

Test Plan: Tried to connect to https://secure.phabricatoraodifnadfnlansldfnak.com/

Reviewers: tido, btrahan, vrana

Reviewed By: tido

CC: aran

Maniphest Tasks: T1105

Differential Revision: https://secure.phabricator.com/D2198
Use HTTPS keepalives in HTTPSFuture if possible

Summary: cURL can manage keepalives as long as you reuse the connection. Since this class is synchronous (despite being a "future"), this is pretty easy. Make appropriate adjustments so we can get HTTPS keepalives.

Test Plan: Ran various "arc" commands under --trace with keepalives, observed dramatic performance improvements for calls 2..N.

Reviewers: btrahan, vrana, jungejason

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D2204
Fix error message in build_xhpast

Summary:
escape backtick

it was displayed as

  ...
  Maybe try  if the error
  ...

Test Plan: run build_xhpast and see 'Static=1...' got displayed.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D2211
Use %C formatter for 'mate' editor on non-Windows hosts

Summary:
In https://secure.phabricator.com/D2055, jungejason fixed command-line
formatting for non-Windows editors that were not TextMate ('mate').

This widens the fix to also apply to TextMate.

Test Plan: Sent out this diff in with EDITOR='mate -w'.

Reviewers: jungejason, nh, epriestley

Reviewed By: epriestley

CC: epriestley, aran

Differential Revision: https://secure.phabricator.com/D2217
Centralize highlighter fallback

Summary:
I think that this API is better because all highlighters don't need to provide a fallback to the default highlighter if anything goes wrong.

But the real motivation comes in the next diff.

Test Plan:
  lang=text
  lang=js
  var a = 1;

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D2226
Don't let <span> cross lines when highlighting Remarkup

Summary:
If a layer above us wraps each line in some other element (like Paste or Differential) we'll end up with invalid markup if a highlighted element crosses a newline.

Instead, before we hit a newline, add a </span> and resume the span afterwards.

Test Plan: Created a paste with an @{article:...} link spanning a newline, got correct highlighting.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D2261
Improve remarkup quotes over multiple lines

Test Plan:
  > a
  > b

  > c
  d

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2265
Highlight `monospace` in Diviner highlighter

Test Plan:
  lang=text
  lang=diviner
  **Hello** `world`!

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2270
Speed up utf8_strlen()

Summary:
  mb_strlen()            3.1 us
  count(phutil_utf8v()) 28.3 us
  strlen(utf8_decode())  1.7 us

Test Plan:
  phutil_utf8_strlen('čeština');

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2280
Explicitly set URL parameter separator for external URLs

Summary: See D2284.

Test Plan:
  arc unit `find . -name __tests__`

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2285
Add PhutilDeferredLog, for logging things later

Summary:
This is a step toward creating a unified access log, which is a Facebook request.

I structured it as an object that logs on destruction because it makes it easier to ensure we log everything while making the logs maximally useful (some information that's useful to put in the logs isn't available until later in the request, e.g. Conduit user).

Test Plan: Ran unit tests.

Reviewers: jungejason, vrana, btrahan

Reviewed By: vrana

CC: aran, ps, Girish

Differential Revision: https://secure.phabricator.com/D2296
Prepare for killing __init__

Summary:
Initial support for libraries without `__init__.php`.
See D2208 for usage.

Test Plan:
  diviner .

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2207