Skip to content

Commit

Permalink
use use namespace
Browse files Browse the repository at this point in the history
Summary:
No change to the commits, just a new PR
Closes #23

Reviewed By: kmeht

Differential Revision: D5651178

Pulled By: kmeht

fbshipit-source-id: 0461b6307a95cd34836bcc97fbb9005bccad24c1
  • Loading branch information
fredemmott authored and facebook-github-bot committed Aug 17, 2017
1 parent f77ee82 commit cde3efb
Show file tree
Hide file tree
Showing 36 changed files with 137 additions and 150 deletions.
22 changes: 10 additions & 12 deletions bin/generate-docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
ScannedTypehint,
TreeParser
};
use HH\Lib\Dict as DictHSL;
use HH\Lib\Vec as VecHSL;
use HH\Lib\{C, Str};
use namespace HH\Lib\{C, Dict, Str, Vec};

require_once(__DIR__.'/../vendor/autoload.php');
require_once(__DIR__.'/../vendor/hh_autoload.php');
Expand All @@ -36,9 +34,9 @@ public function createInDirectory($path): void {

$namespaces_funcs = TreeParser::FromPath(__DIR__.'/../src/')
->getFunctions()
|>DictHSL\group_by($$, $f ==> $f->getNamespaceName())
|>DictHSL\sort_by_key($$)
|>DictHSL\filter_keys(
|>Dict\group_by($$, $f ==> $f->getNamespaceName())
|>Dict\sort_by_key($$)
|>Dict\filter_keys(
$$,
$ns ==> $ns !== '' && $ns !== "HH\\Lib\\_Private",
);
Expand All @@ -53,8 +51,8 @@ public function createInDirectory($path): void {
}

$namespaces_funcs
|>VecHSL\keys($$)
|>VecHSL\map(
|>Vec\keys($$)
|>Vec\map(
$$,
$ns ==> sprintf(
" - [%s](%s)",
Expand All @@ -74,7 +72,7 @@ private function getMarkdownForNamespace(
string $ns,
vec<ScannedFunction> $funcs,
): string {
$funcs = VecHSL\sort_by($funcs, $f ==> $f->getShortName());
$funcs = Vec\sort_by($funcs, $f ==> $f->getShortName());
$short_ns = Str\strip_prefix($ns, "HH\\Lib\\");
$out = sprintf("# %s\n\n", $ns);

Expand Down Expand Up @@ -159,7 +157,7 @@ private function renderGenerics(
return null;
}

$parts = VecHSL\map($g, $g ==> $this->renderGeneric($g));
$parts = Vec\map($g, $g ==> $this->renderGeneric($g));

if ($multiline) {
return "<\n ".Str\join(",\n ", $parts)."\n>";
Expand Down Expand Up @@ -195,7 +193,7 @@ private function renderParameters(
if (C\is_empty($f->getParameters())) {
return '()';
}
$parts = VecHSL\map($f->getParameters(), $p ==> $this->renderParameter($p));
$parts = Vec\map($f->getParameters(), $p ==> $this->renderParameter($p));
if ($multiline_parameters) {
$trailing_comma = Str\contains(C\lastx($parts), '...') ? '' : ',';
return "(\n ".Str\join(",\n ", $parts).$trailing_comma."\n)";
Expand Down Expand Up @@ -253,7 +251,7 @@ private function renderDocComment(ScannedFunction $f): ?string {
|>Str\strip_suffix($$, '*/')
|>Str\trim($$)
|>Str\split("\n", $$)
|>VecHSL\map($$, $s ==> Str\trim(Str\strip_prefix(Str\trim($s), '*')))
|>Vec\map($$, $s ==> Str\trim(Str\strip_prefix(Str\trim($s), '*')))
|>Str\join("\n", $$)
|>$$."\n";
}
Expand Down
2 changes: 1 addition & 1 deletion src/dict/combine.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace HH\Lib\Dict;

use \HH\Lib\C;
use namespace \HH\Lib\C;

/**
* Returns a new dict where each element in `$keys` maps to the
Expand Down
2 changes: 1 addition & 1 deletion src/dict/introspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace HH\Lib\Dict;

use \HH\Lib\C;
use namespace \HH\Lib\C;

/**
* Returns whether the two given dicts have the same entries, using strict
Expand Down
2 changes: 1 addition & 1 deletion src/dict/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace HH\Lib\Dict;

use \HH\Lib\Vec;
use namespace \HH\Lib\Vec;

/**
* Returns a new dict with the original key/value pairs in reversed iteration
Expand Down
2 changes: 1 addition & 1 deletion src/keyset/introspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace HH\Lib\Keyset;

use \HH\Lib\C;
use namespace \HH\Lib\C;

/**
* Returns whether the two given keysets have the same elements, using strict
Expand Down
3 changes: 1 addition & 2 deletions src/math/compute.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
*/

namespace HH\Lib\Math;
use HH\Lib\C;
use HH\Lib\Str;
use namespace HH\Lib\{C, Str};
use const HH\Lib\_Private\ALPHABET_ALPHANUMERIC;

/**
Expand Down
4 changes: 1 addition & 3 deletions src/math/containers.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
*/

namespace HH\Lib\Math;
use HH\Lib\C;
use HH\Lib\Math;
use HH\Lib\Vec;
use namespace HH\Lib\{C, Math, Vec};

/**
* Returns the largest of all input numbers.
Expand Down
5 changes: 1 addition & 4 deletions src/vec/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@

namespace HH\Lib\Vec;

use \HH\Lib\C;
use \HH\Lib\Dict;
use \HH\Lib\Math;
use \HH\Lib\Str;
use namespace \HH\Lib\{C, Dict, Math, Str};

/**
* Returns a new vec containing the range of numbers from `$start` to `$end`
Expand Down
3 changes: 1 addition & 2 deletions src/vec/select.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

namespace HH\Lib\Vec;

use \HH\Lib\Dict;
use \HH\Lib\Keyset;
use namespace \HH\Lib\{Dict, Keyset};

/**
* Returns a new vec containing only the elements of the first Traversable that
Expand Down
2 changes: 1 addition & 1 deletion tests/c/CIntrospectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
*/

use \HH\Lib\C as C;
use namespace \HH\Lib\C;
use function \Facebook\FBExpect\expect;

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/c/CReduceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
*/

use \HH\Lib\C as C;
use namespace \HH\Lib\C;
use function \Facebook\FBExpect\expect;

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/c/CSelectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
*/

use \HH\Lib\C as C;
use namespace \HH\Lib\C;
use function \Facebook\FBExpect\expect;
// @oss-disable: use InvariantViolationException as InvariantException;

Expand Down
6 changes: 3 additions & 3 deletions tests/dict/DictCombineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
*/

use \HH\Lib\Dict as DictHSL;
use namespace \HH\Lib\Dict;
use function \Facebook\FBExpect\expect;

/**
Expand Down Expand Up @@ -61,7 +61,7 @@ public function testAssociate<Tk as arraykey, Tv>(
Traversable<Tv> $values,
dict<Tk, Tv> $expected,
): void {
expect(DictHSL\associate($keys, $values))->toBeSame($expected);
expect(Dict\associate($keys, $values))->toBeSame($expected);
}

public static function provideTestMerge(): array<mixed> {
Expand Down Expand Up @@ -124,6 +124,6 @@ public function testMerge<Tk, Tv>(
Container<KeyedTraversable<Tk, Tv>> $traversables,
dict<Tk, Tv> $expected,
): void {
expect(DictHSL\merge(...$traversables))->toBeSame($expected);
expect(Dict\merge(...$traversables))->toBeSame($expected);
}
}
6 changes: 3 additions & 3 deletions tests/dict/DictDivideTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
*/

use \HH\Lib\Dict as DictHSL;
use namespace \HH\Lib\Dict;
use function \Facebook\FBExpect\expect;

/**
Expand Down Expand Up @@ -113,7 +113,7 @@ public function testPartition<Tk, Tv>(
(function(Tv): bool) $predicate,
(dict<Tk, Tv>, dict<Tk, Tv>) $expected,
): void {
expect(DictHSL\partition($traversable, $predicate))->toBeSame($expected);
expect(Dict\partition($traversable, $predicate))->toBeSame($expected);
}

/** @dataProvider providePartitionWithKey */
Expand All @@ -122,6 +122,6 @@ public function testPartitionWithKey<Tk, Tv>(
(function(Tk, Tv): bool) $predicate,
(dict<Tk, Tv>, dict<Tk, Tv>) $expected,
): void {
expect(DictHSL\partition_with_key($traversable, $predicate))->toBeSame($expected);
expect(Dict\partition_with_key($traversable, $predicate))->toBeSame($expected);
}
}
4 changes: 2 additions & 2 deletions tests/dict/DictIntrospectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
*/

use \HH\Lib\Dict as DictHSL;
use namespace \HH\Lib\Dict;
use function \Facebook\FBExpect\expect;

/**
Expand Down Expand Up @@ -58,6 +58,6 @@ public function testEqual<Tk, Tv>(
dict<Tk, Tv> $dict2,
bool $expected,
): void {
expect(DictHSL\equal($dict1, $dict2))->toBeSame($expected);
expect(Dict\equal($dict1, $dict2))->toBeSame($expected);
}
}
10 changes: 5 additions & 5 deletions tests/dict/DictOrderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
*/

use \HH\Lib\Dict as DictHSL;
use namespace \HH\Lib\Dict;
use function \Facebook\FBExpect\expect;

/**
Expand Down Expand Up @@ -55,7 +55,7 @@ public function testReverse<Tk as arraykey, Tv>(
KeyedTraversable<Tk, Tv> $traversable,
dict<Tk, Tv> $expected,
): void {
expect(DictHSL\reverse($traversable))->toBeSame($expected);
expect(Dict\reverse($traversable))->toBeSame($expected);
}

public static function provideTestSort(): array<mixed> {
Expand Down Expand Up @@ -129,7 +129,7 @@ public function testSort<Tk, Tv>(
?(function(Tv, Tv): int) $value_comparator,
dict<Tk, Tv> $expected,
): void {
expect(DictHSL\sort($traversable, $value_comparator))->toBeSame($expected);
expect(Dict\sort($traversable, $value_comparator))->toBeSame($expected);
}

public static function provideTestSortBy(): array<mixed> {
Expand Down Expand Up @@ -174,7 +174,7 @@ public function testSortBy<Tk, Tv, Ts>(
?(function(Ts, Ts): int) $scalar_comparator,
dict<Tk, Tv> $expected,
): void {
expect(DictHSL\sort_by($traversable, $scalar_func, $scalar_comparator))
expect(Dict\sort_by($traversable, $scalar_func, $scalar_comparator))
->toBeSame($expected);
}

Expand Down Expand Up @@ -218,7 +218,7 @@ public function testSortByKey<Tk, Tv>(
?(function(Tk, Tk): int) $key_comparator,
dict<Tk, Tv> $expected,
): void {
expect(DictHSL\sort_by_key($traversable, $key_comparator))
expect(Dict\sort_by_key($traversable, $key_comparator))
->toBeSame($expected);
}
}
Loading

0 comments on commit cde3efb

Please sign in to comment.