Load all functions when loading a libphutil library

Summary: We can't autoload these, so just load them at startup. This means we don't need to write dependencies for them into __init__.php, which moves us closer to being able to remove __init__.php.

Test Plan: Ran "arc diff", loaded Phabricator.

Reviewers: vrana, btrahan, jungejason

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2545
Use gmake instead of make if its available to make it compile on FreeBSD

Summary: Use gmake instead of make if its available

Test Plan: I've tried it on FreeBSD, Ubuntu and CentOS

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D2546
Add a console highlighter and language guesser

Summary: Pygments has a console highlighter but it doesn't handle path prefixes and doesn't ephasize comments enough. Add a fancier highlighter and a guesser.

Test Plan: {F11792}

Reviewers: btrahan, vrana, jungejason

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D2539
Provide information about wrong value passed to assert_instances_of()

Test Plan:
  assert_instances_of(array(1), 'stdClass');
  assert_instances_of(array(new stdClass), 'C');
  assert_instances_of(array(new stdClass), 'stdClass');

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2554
Minor, escape console output after parsing so quotes don't trigger the "#" comment rule.
Revert "Load all functions when loading a libphutil library"

Summary:
This reverts commit 3475788eddcace2eb71665a50565d74deaef62e0.

We can't do this without doing more comprehensive changes at the same time. There are two problems:

  - We may load some function which, e.g., does "new X()" in its implementation, triggering an include of a module which defines class X. This class may extend a class in another library which hasn't loaded yet. We could fix this problem by ignoring `phutil_require_module()` during function autoload, but can't fix the next one.
  - We may load some function which is defined in a module which also defines some class X, which extends a class in another library which hasn't loaded yet.

We need to wait to land this to avoid triggering these problems.

Test Plan: Strict revert.

Reviewers: nh, vrana, btrahan

Reviewed By: nh

CC: aran

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2556
Avoid E_NOTICE

Auditors: epriestley
Move Futures() to a separate file

Summary: Also use `assert_instances_of()`.

Test Plan: `arc liberate`

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2563
Create a script for killing __init__.php

Summary:
Maybe we should integrate it in `arc liberate`.
Maybe it should support non-Git repositories.
But this is all I have.

Test Plan: Run it on Arcanist and Diviner.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2566
Support history in phutil_console_prompt()

Summary:
I've tried several approaches, this is the only one which works for me:

- There's almost no chance that `readline()` will be available in PHP so I don't even check it.
- I wasn't able to convince `execx()` to read the input.
- I wasn't able to convince `phutil_passthru()` to give me the $REPLY or output.
- Good old `shell_exec()` works.

I'm not sure if `read -p` supports colors but they are not much useful here.
I need to use `read -p` instead of echo otherwise the prompt is cleared with scrolling.

Test Plan:
  phutil_console_prompt('Write:', '/tmp/history-test');

- Run several times.
- Input different strings.
- Scroll in history.
- Provide empty input.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2579
WIP
Split phlog() out of a class definition file

Summary: We can't put functions and classes in the same file any longer.

Test Plan:
This warning vanished from the new linter:

  >>> Lint for /INSECURE/devtools/libphutil/src/error/PhutilErrorHandler.php:

     Error  (PHL3) One Class Per File
      File 'error/PhutilErrorHandler.php' mixes function (phlog,
      phutil_error_listener_example) and class/interface (PhutilErrorHandler)
      definitions in the same file. A file which declares a class or an
      interface MUST declare nothing else.

               342  * @return void
               343  * @group error
               344  */
               345 function phutil_error_listener_example($event, $value, array $metadata) {
               346   throw new Exception("This is just an example function!");
               347 }

Also ran 'arc' and loaded Phabricator.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2596
Increase default HTTP/Conduit timeouts to 5 minutes

Summary: Realistically, some operations are pretty slow. These conservative timeouts don't actually help with diagnosis or troubleshooting (a hang vs a timeout tells us nothing useful, really) so bump them up to 5 minutes.

Test Plan: Read carefully.

Reviewers: phleet, vrana, btrahan

Reviewed By: phleet

CC: aran

Differential Revision: https://secure.phabricator.com/D2602
Support loading v2 libraries in libphutil

Summary:

  - When loading a v2 library, load all its functions.
  - When loading a library, build the classtree at load time instead of when we run a PhutilSymbolLoader query with `setAncestorClass`. This is slightly less efficient for the common case (zero calls), but simpler.
  - Ignore phutil_require_module() calls that load v2 library modules, so a v1 library can continue to reference a v2 library.
  - Load symbols in v2 libraries by loading the appropriate files.

Test Plan: Converted libphutil, arcanist and phabricator to v2, one at a time. Loaded stuff in Phabricator.

Reviewers: vrana, nh, btrahan

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2587
Upgrade libphutil to libphutil v2

Summary: Mechanical changes from D2588. No "Class.php" moves yet.

Test Plan: See D2588

Reviewers: vrana, btrahan, jungejason

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2590
Remove phutil_require_module() from scripts and docs

Test Plan:
  ./utf8.php

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2608
Use `-O encoding=utf-8` for pygmentize

Summary:
Explicitly specify UTF-8 encoding, as we use it internally and it resolves at least one real-world problem @auduny ran into.

The test case ("tettpånett") works fine for me with or without this change, but I'm guessing my pygments defaults to utf8 for some reason. It seems like making the encoding we expect explicit can't hurt anything.

Test Plan:
  - Looked at some highlighted files on my system, everything worked properly.
  - @auduny reported that this resolved an issue he encountered.

Reviewers: auduny, btrahan, vrana

Reviewed By: auduny

CC: aran

Differential Revision: https://secure.phabricator.com/D2617
Remove PhutilSymbolLoader::loadClass(), add setPathPrefix()

Summary:
  - There are no more callsites to loadClass(); get rid of it.
  - Add setPathPrefix() to replace setModule(), we need this for unit tests.

Test Plan: Fixed unit tests for v2. Grepped for loadClass().

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2621
Tell HipHop PHP to log errors

Summary:
HipHop won't log errors unless you set log_errors to true.  This is
either on by default in Zend installations currently using phd, or
irrelevant.

http://www.php.net/manual/en/errorfunc.configuration.php#ini.log-errors

Test Plan:
Added error_log($random_number) to PhutilNiceDaemon, and launched it
using HipHop.  Saw this in the log file:

  Bringing daemon 'PhutilNiceDaemon' online...
  a random number: 53707991
  a random number: 1823619280
  a random number: 1822487120
  a random number: 564506024
  ...

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2626
Fix typos