From 1e961dba7cc4f7f157c2b957bbe23e63408f4536 Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Fri, 25 Aug 2017 10:59:28 -0700 Subject: [PATCH] Stub out PHPism and FBLogger Summary: Closes https://github.com/hhvm/hsl/pull/26 Reviewed By: savil Differential Revision: D5707518 Pulled By: savil fbshipit-source-id: 3009d2ad40581d9029be7bdfdd61eaaffc8fdb3b --- src/keyset/transform.php | 6 +++++- src/private.php | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/keyset/transform.php b/src/keyset/transform.php index 840bd65a..0a9c0337 100644 --- a/src/keyset/transform.php +++ b/src/keyset/transform.php @@ -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. @@ -78,7 +82,7 @@ function flatten( ): keyset { $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'); diff --git a/src/private.php b/src/private.php index bc1e0853..5ab11636 100644 --- a/src/private.php +++ b/src/private.php @@ -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(Traversable $_): 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';