From 16b10176d1ae3e8ab9deb48007324b13c13d93a4 Mon Sep 17 00:00:00 2001 From: Lexidor Digital <31805625+lexidor@users.noreply.github.com> Date: Thu, 31 Oct 2019 21:29:41 +0100 Subject: [PATCH] Support `disallow_silence` (#21) * Make fbexpect meet `disallow_silence` * Enable strict options that introduce test failures * Require HHVM 4.25 for HHI support of array_literal --- .hhconfig | 5 ++--- src/Constraint/IsType.hack | 17 +++++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.hhconfig b/.hhconfig index 4f68223..5c135cb 100644 --- a/.hhconfig +++ b/.hhconfig @@ -6,6 +6,5 @@ disallow_unsafe_comparisons=true decl_override_require_hint=true enable_experimental_tc_features=shape_field_check,sealed_classes user_attributes= - -; Once the minimum hhvm version hits 4.25 this setting can be safely enabled -disallow_array_literal = false +disallow_array_literal = true +disallow_silence = true diff --git a/src/Constraint/IsType.hack b/src/Constraint/IsType.hack index 8d24113..fe77f76 100644 --- a/src/Constraint/IsType.hack +++ b/src/Constraint/IsType.hack @@ -30,12 +30,17 @@ class IsType { 'array' => ($x ==> \is_array($x)), 'object' => ($x ==> \is_object($x)), 'resource' => ( - $x ==> ($x is resource) || - ( - @\get_resource_type( - /* HH_FIXME[4110] closed resources fail is resource */ $x, - ) is string - ) + $x ==> { + if ($x is resource) { + return true; + } + $error_level = \error_reporting(0); + $is_resource = \get_resource_type( + /* HH_FIXME[4110] closed resources fail is resource */ $x, + ) is string; + \error_reporting($error_level); + return $is_resource; + } ), 'scalar' => ($x ==> \is_scalar($x)), 'callable' => ($x ==> \is_callable($x)),