Update `.gitignore`.

Summary: See inline comments for reasoning.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9530
Fix phutil_utf8_console_strlen() for combining characters

Summary:
See D9533. We currently count the length of combining characters incorrectly.

Instead, break the string into glyphs first, then only count the length of the base character in each glyph, ignoring combining characters.

Test Plan: Added some unit tests.

Reviewers: joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D9546
Reduce the amount of information leaked into stack traces

Summary:
Via HackerOne. We currently expose the daemon log in the web UI. The utility of doing this is large, but stack traces may occasionally contain too much information.

Instead of printing out function arguments in stack traces, just print out the types. This is at least as useful in most cases, and can't leak anything sensitive.

Also, when possible, canonicalize paths in stack traces relative to a known library. This makes them slightly more readable, and may reduce the number of researchers reporting full path disclosure via HackerOne.

Test Plan:
Ran something like this:

```
function f() {
  throw new Exception("ABCDEF");
}

f("a", 1, null, false, (object)array(), array(), new PhutilJSON());
```

...and got this stack trace:

```
>>> orbital ~/devtools/libphutil $ ./scripts/test/prompt.php
[2014-06-14 19:14:45] EXCEPTION: (Exception) ABCDEF at [<phutil>/scripts/test/prompt.php:8]
  #0 f(string, integer, NULL, boolean, stdClass, array, PhutilJSON) called at [<phutil>/scripts/test/prompt.php:11]
```

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D9540
Add a `PhutilConsoleTable` class for drawing tables.

Summary: Currently there is no easy way to draw a table. `PhabricatorDaemonManagementStatusWorkflow` draws a table in an ad-hoc way, but it would be useful to provide a more flexible mechanism to do so.

Test Plan:
```lang=php
$table = id(new PhutilConsoleTable())
  ->addColumn('foo', array('title' => 'Foo', 'align' => 'right'))
  ->addColumn('bar', array('title' => 'Foobar', 'align' => 'center'))
  ->addColumn('baz', array('title' => '日本語'))

  ->addRow(array('foo' => 12345, 'bar' => 'foo', 'baz' => 'baz'))
  ->addRow(array('foo' => '汉语漢語', 'bar' => '한국어조선말', 'baz' => 'ру́сский язы́к'))
  ->addRow(array('foo' => 'aaa', 'bar' => '✓✗', 'baz' => 'dddddddddddd'))
  ->addRow(array('foo' => '', 'bar' => '', 'baz' => ''));

$table->setBorders(false)->draw();
echo "\n";
$table->setBorders(true)->draw();
```

**Output**
{F166929}

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9533
Add a `addColumns` method to `PhutilConsoleTable`.

Summary: Allow columns to be added in one big hit. In some cases, this may be easier than adding columns individually.

Test Plan: Meh

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9553
Rebuild libphutil library map to remove `sprintf_escape` function

Summary: Minor, fix out-of-date build after D9533.

Test Plan: `arc liberate`

Reviewers: joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D9556
Move infrastructure tests up one directory.

Summary: Sometimes, the `PhutilInfrastructureTestCase` //would// fail, but we don't run it with `arc unit` because of the directory structure. See D9556 for an example.

Test Plan: Ran `arc unit --everything` and verified that `PhutilInfrastructureTestCase` was executed.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9557
Support ansicon for ANSI support on Windows

Summary: This gives more color. See: https://github.com/adoxa/ansicon

Test Plan: run `arc unit` amongst others and see spiffy colors

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9560
Rebuild `xhpast.exe` with static linkage

Summary:
Fixes T5372.

This thing is like 2.5MB but surely we will never regret checking multi-megabyte binaries into the VCS.

Test Plan:
  - Observed static flags being used during build.
  - Ran `xhpast.exe` with some PHP piped into it.
  - Saw large binary size.

Reviewers: richardvanvelzen

Reviewed By: richardvanvelzen

Subscribers: epriestley

Maniphest Tasks: T5372

Differential Revision: https://secure.phabricator.com/D9581
Fix the width of `PhutilConsoleTable` if the header row is wider than the data rows.

Summary:
Currently, the width of the header text is not taken into consideration when drawing the table. The width of the header text must be accounted for as if it were an ordinary row. Specifically, the following error occurs otherwise:

```
PHP Warning:  str_repeat(): Second argument has to be greater than or equal to 0 in /home/joshua/workspace/github.com/phacility/libphutil/src/console/PhutilConsoleTable.php on line 211
```

Test Plan: Drew a table with a really wide header column. verified that no warnings were raised and that the table rendered correctly.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9583
Allow PhutilConsoleProgressBar to be quiet

Summary:
This allows you to use the progress bar even if you don't want it to output anything. This can simplify logic in other parts of your code.

  $progress = new PhutilConsoleProgressBar();
  $progress->setQuiet(true);
  // etc.

Test Plan: derpy

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9586
Add a method to `PhutilConsoleTable` to hide the header.

Summary: Add a `setShowHeader` method to `PhutilConsoleTable` so that the header row can be hidden.

Test Plan:
Constructed a headerless table.

```
+==========+==========+=====================+
|    12345 | alicoln  | abraham@lincoln.com |
| 99999999 | jbloggs  | joe@bloggs.com      |
+==========+==========+=====================+
```

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9596
Ignore colors and formatting when determining string length.

Summary:
When calculating the length of a string with `phutil_utf8_console_strlen`, escape codes shouldn't contribute any width to the string.

This change allows for the widths of a `PhutilConsoleTable` table to be determined correctly when using rows containing formatting and/or colors.

Test Plan:
**Before**
{F167511}

**After**
{F167512}

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9597
Modernize `.arclint` file.

Summary:
Update the `.arclint` file after D9576 and D9590.

Depends on D9576, D9590.

Test Plan: Eyeball it.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9592
Don't create directories as `0777` by default.

Summary: Currently, `Filesystem::createDirectory('...')` will create a directory with (rather open) `0777` permissions (regardless of the return value of `umask()`). In particular, the `.git/arc` directory (or similar directory for another VCS) will have `0777` permissions.

Test Plan: Removed the `.git/arc` directory and ran `arc lint`. Verified that the `.git/arc` directory had more restrictive permissions than `0777`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9594
Fixing so that on windows local paths to binaries can be used

Summary: On windows, using something like "vendor/bin/phpcs" does not work because the code tries to run "where vendor/bin/phpcs" which fails badly. So instead, when we try to test for a binary on windows, we first check if a file exists locally with that name. If it does, just use that. If someone has a file in their project with the same name as a linter, but that is not the actual linter, this could fail, but I can't imagine a case where that would happen.

Test Plan: On windows, run `arc lint` with a linter configured that is local e.g. "vendor/bin/phpcs"

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9493
Pass additional arguments to the `PhabricatorDaemonEventListener`.

Summary: Include non-standard command line arguments in the `daemon.didLaunch` event.

Test Plan: See D9607.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9613
Fix failing unit test.

Summary: On PHP versions earlier than 5.4.0, `\e` is not a valid PHP escape character. Consequently, `PhutilUTF8TestCase::testUTF8ConsoleStrlen` will fail. Replace `\e` by its hexadecimal equivalent.

Test Plan: Ran unit tests.

Reviewers: hach-que, epriestley, #blessed_reviewers

Reviewed By: hach-que, epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9615
Rename `interestingArgv` to `explicitArgv`.

Summary: `interestingArgv` isn't a very useful name, see D9607#45.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9617
Fix `PhutilReadableSerializer` to quote strings.

Summary: See D9622#inline-37279 for explanation.

Test Plan: Modified and ran unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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