Add support for HTTP headers to HTTPSFuture

Summary: https://github.com/facebook/libphutil/pull/10

Test Play: iiam

Reviewed by: epriestley
Don't leak $root when initializing libphutil scripts

Summary: We leak the global variable $root into the including context, which can ruin things. Put the whole thing in a function.

Test Plan: Ran arc, mail_handler.php.

Reviewers: Makinde, btrahan

Reviewed By: Makinde

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1997
Set a default timezone if the environment doesn't provide one

Summary: See comment.

Test Plan: Deleted my env timezone. Ran a script with strtotime(), got yelled at. Applied patch, strtotime() works cleanly.

Reviewers: Makinde, btrahan

Reviewed By: Makinde

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D2000
Improve phutil_console_wrap()'s ability to deal with ANSI color codes

Summary: phutil_console_wrap() gets color codes and utf8 characters wrong right now. Get them right.

Test Plan: See test coverage.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D2016
Check if array values are instances of something

Summary:
The main motivation for this change is that I sometimes dig down to some code and I wonder what's the type of a passed array.
It also promotes strong typing.

Test Plan:
Display diff with invalid Remarkup rule.
Fix it.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D2042
Avoid double indenting in console wrapping

Summary:
D2016 changed the behavior of `phutil_console_wrap()`.
The new behavior is better so I am fixing callsites instead of the function.

Test Plan:
  arc lint

Verify that the "Apply this patch" prompt is indented only 4 spaces.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D2046
Fix PhutilInteractiveEditor if the user's $EDITOR contains space

Summary:
On linux if $EDITOR contains spaces, the editor will fail to launch. Use
%C instead of %s.

Test Plan:
arc diff works again with ##export EDITOR="/usr/bin/emacs -q"##

Reviewers: epriestley, nh

Reviewed By: nh

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D2055
Fix reuse of locals as iterators in libphutil

Summary:
Only one hit here. It did not cause a bug, but is unconventional. Use a more conventional construction.

Also added some test coverage.

Test Plan: Ran tests.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D2051
Improve copy/paste from Diviner

Summary: Change <code> tag to <pre> and modify the related test cases

Test Plan: Run ../arcanist/bin/arc unit /home/hwang/devtools/libphutil/src/markup/engine/remarkup/blockrule/remarkupcode

Reviewers: epriestley

Reviewed By: epriestley

CC: jungejason, aran

Maniphest Tasks: T207

Differential Revision: https://secure.phabricator.com/D2067
Return $this from setters

Summary:
Most setters returns `$this` but some don't.
I guess it's not by purpose.

Test Plan:
  arc lint

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D2083
Allow [[]] remarkup links outside Phabricator

Summary: Namely at [[http://phabricator.com/docs/phabricator/article/Give_Feedback!_Get_Support!.html | /docs/article/Give_Feedback!_Get_Support!.html]].

Test Plan:
  [[wiki]]
  [[http://example.com]]
  [[http://example.com | example.com]]

Regenerate docs.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D2110
Support Windows

Test Plan:
  var_dump(phutil_console_prompt(''));

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D2116
Fix PhutilMissingSymbolException documentation pointer

Summary: See rPHU91e4f9144e944c2653ce85174abc26099afa61d1. The controlling documentation moved to Phabricator after 'arc liberate', tailor the instructions for modern toolsets / doc locations.

Test Plan: Added "new Derp()" to a script, ran it, got a more useful/actionable error.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D2129
Improve Windows support

Test Plan: Display stacktrace in Phabricator, verify that filenames are links.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D2131
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