Skip to content

Commit

Permalink
Stub out PHPism and FBLogger
Browse files Browse the repository at this point in the history
Summary: Closes #26

Reviewed By: savil

Differential Revision: D5707518

Pulled By: savil

fbshipit-source-id: 3009d2ad40581d9029be7bdfdd61eaaffc8fdb3b
  • Loading branch information
fredemmott authored and Fred Emmott committed Aug 25, 2017
1 parent d0da33d commit 1e961db
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/keyset/transform.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

namespace HH\Lib\Keyset;

// @oss-disable: use \PHPism_FIXME as PHPism_FIXME;
use HH\Lib\_Private\StubPHPism_FIXME as PHPism_FIXME; // @oss-enable
use function HH\Lib\_Private\universal_chainable_stub as FBLogger; // @oss-enable

/**
* Returns a vec containing the given Traversable split into chunks of the
* given size.
Expand Down Expand Up @@ -78,7 +82,7 @@ function flatten<Tv as arraykey>(
): keyset<Tv> {
$result = keyset[];
foreach ($traversables as $traversable) {
if (!\PHPism_FIXME::isForeachable($traversable)) {
if (!PHPism_FIXME::isForeachable($traversable)) {
FBLogger('phpism_fixme.invalid_foreach_arg')
->blameToPreviousFrame()
->mustfix('Attempting to foreach over a non-foreachable type');
Expand Down
19 changes: 19 additions & 0 deletions src/private.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,24 @@ function validate_offset(
return $offset;
}

// Stub implementations of FB internals used to ease migrations

/* HH_IGNORE_ERROR[5520] FIXME violates FB naming conventions */
final class StubPHPism_FIXME {
public static function isForeachable<T>(Traversable<T> $_): bool {
return true;
}
}

final class UniversalChainableStub {
public function __call(mixed $_, mixed $_): this {
return $this;
}
}

function universal_chainable_stub(mixed ...$_): UniversalChainableStub {
return new UniversalChainableStub();
}

const string ALPHABET_ALPHANUMERIC =
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

0 comments on commit 1e961db

Please sign in to comment.