Rebuild library map

Summary: Rebuild library map after D9787.

Test Plan: I forgot to run `arc liberate` as a part of D9787.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9814
Move `PhutilLibraryMapBuilder` to `libphutil`

Summary: Move `scripts/phutil_rebuild_map.php` and the `PhutilLibraryMapBuilder` class from rARC to rPHU. The intention here is to create a stronger `ArcanistInfrastructureTestCase` acceptance test (and the corresponding acceptance tests for rP and rPHU) by regenerating the library map file (to a temporary output) and comparing it to the existing library map file. This will be able to catch the case in which a new class/function has been added to a library, but `arc liberate` has not been executed.

Test Plan:
```
> ./scripts/phutil_rebuild_map.php src
Finding source files...
Found 344 files.
Loading symbol cache...
Found 344 files in cache.
Building library map...
Writing map...
Done.
```

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9813
Move `PhutilBootloader` into the standard directory structure

Summary: Move `PhutilBootloader` and other related classes/functions into the standard directory structure. Whilst there is no compelling reason that we have to do this, it does make the code in `libphutil/src/__phutil_library_init__.php` a bit cleaner.

Test Plan: Verfied that `arc liberate` and `arc unit` still worked.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9818
Add an `appendPath` method to `PhutilURI`

Summary: This method would primarily be useful when you have a `PhutilURI` (which may or may not have a path) and you would like to define a path relative to the existing URI.

Test Plan: Wrote and executed unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9823
Add an `externals/includes` directory

Summary: Add an `externals/includes` directory that will be included as a part of PHP's `include_path`. Arcanist already has similar functionality. Without this, it is hard to invoke the `scripts/update_compat_info.php` script, which was moved from rARC to rPHU in D9813.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9821
Move `PhutilLibraryMapBuilder` into the standard directory structure

Summary: See D9818.

Test Plan: Made sure `arc liberate` still works.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9822
Improve the `PhutilInfrastructureTestCase` unit tests

Summary:
Improve the `PhutilInfrastructureTestCase` unit tests such that they will fail if any of the following conditions are satisfied:

- A symbol referenced in the `__phutil_library_map__.php` file no longer exists.
- A symbol exists in the library but is not referenced within the `__phutil_library_map__.php` file.
- A symbol extends from a different parent symbol than that declared in the `__phutil_library_map.php` file.

Test Plan: Added a new function. Ran `arc unit` and observed the test failure.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9824
Add a `phutil_get_current_library_name` function

Summary: See https://secure.phabricator.com/D9827?id=23585#inline-37952

Test Plan: Called the function from within `arcanist` and verified that `'arcanist'` was returned.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9828
Disregard `src/extensions/` when running library map unit tests

Summary:
The runtime map will include anything loaded via `src/extensions/`, which means the test will always fail if you have anything in that directory.

Instead, allow the base (no extensions) map to be retrieved, and use that for comparisions.

Test Plan:
  - Ran unit tests with stuff in extensions.
  - Verified stuff in extensions still works fine.

Reviewers: joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D9834
Minor change to `PhutilInfrastructureTestCase::testLibraryMap`

Summary: Modify `PhutilInfrastructureTestCase::testLibraryMap` to use `phutil_get_current_library_name()` instead of hard-coding the library name.

Test Plan: Ran `arc unit`, tests passed. Added a new function without running `arc liberate`, tests failed.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9844
Minor modification to `PhutilJSONParser` documentation

Summary: The `PhutilJSONParser` class is reasonably stable, we no longer need to advise against using it.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9853
Set the `PhutilLibraryMapBuilder` to be quiet by default

Summary: Most of the cases in which `PhutilLibraryMapBuilder` would be used, it is likely that quiet mode would be desired. The only real exception is `./scripts/phutil_rebuild_map.php`.

Test Plan: Ran `./scripts/phutil_rebuild_map.php src` and `./scripts/phutil_rebuild_map.php --quiet src`.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9860
Separate map building and updating in `PhutilLibraryMapBuilder`

Summary: Separate the building of the library map from the writing of the library map to file. This is a much nicer approach.

Test Plan: Ran `./scripts/phutil_rebuild_map.php src` and `./scripts/phutil_rebuild_map.php --show src`.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9861
Remove `@group` annotations

Summary: I'm pretty sure that `@group` annotations are useless now... see D9855.

Test Plan: Eye-ball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9856
Throw an exception instead of exiting

Summary: Ref T5577. The `PhutilLibraryMapBuilder` should throw a `XHPASTSyntaxErrorException` exception instead of calling `exit`.

Test Plan: See D9865.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5577

Differential Revision: https://secure.phabricator.com/D9867
Remove blank line between docblock and function call

Summary: Minor change. Remove a blank line so that the docblock and function call are touching (in the `__phutil_library_map__.php` file).

Test Plan: Ran `arc liberate`.

Reviewers: epriestley, #blessed_reviewers, chad

Reviewed By: #blessed_reviewers, chad

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9869
Fix duplicated "Done" output

Summary: `PhutilLibraryMapBuilder` outputs "Done" twice, once implicitly from `PhutilConsoleProgressBar` and another explicitly.

Test Plan:
**Before**
```
> arc liberate src
Finding source files...
Found 350 files.
Loading symbol cache...
Found 0 files in cache.
Analyzing 350 files with 8 subprocesses...
Done.

Done.
Building library map...
Writing map...
```

**After**
```
> arc liberate src
Finding source files...
Found 350 files.
Loading symbol cache...
Found 349 files in cache.
Analyzing 1 files with 8 subprocesses...
Done.
Building library map...
Writing map...
```

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9870
Delete some old draft documentation

Summary: I'm not sure what this "draft" documentation is exactly, but the lines are too long and it saddens me deeply. Let's just delete them for now... if they are needed at a later date then we can dig them out of version control.

Test Plan: Felt less sad.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9897
Show file where syntax error occurred in library map builder

Summary: Fixes T5597. This information is pretty useful but was inadvertently dropped while cleaning up some other stuff.

Test Plan: Ran `arc liberate`, was told which file has the issue.

Reviewers: joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T5597

Differential Revision: https://secure.phabricator.com/D9883
Fix some spelling mistakes

Summary: Found some spelling mistakes by running `arc lint --everything` over the repository.

Test Plan: Eye-ball it.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

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