diff --git a/src/Constraint/IsType.hack b/src/Constraint/IsType.hack index 7a77db3..8d24113 100644 --- a/src/Constraint/IsType.hack +++ b/src/Constraint/IsType.hack @@ -30,9 +30,12 @@ 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 ==> ($x is resource) || + ( + @\get_resource_type( + /* HH_FIXME[4110] closed resources fail is resource */ $x, + ) is string + ) ), 'scalar' => ($x ==> \is_scalar($x)), 'callable' => ($x ==> \is_callable($x)), diff --git a/src/ExpectObj.hack b/src/ExpectObj.hack index 4d9f743..fd38745 100644 --- a/src/ExpectObj.hack +++ b/src/ExpectObj.hack @@ -234,7 +234,7 @@ class ExpectObj extends Assert { TVal $needle, string $msg = '', mixed ...$args - ): void where T as Traversable{ + ): void where T as Traversable { $msg = \vsprintf($msg, $args); $this->assertContains($needle, not_hack_array($this->var), $msg); } @@ -454,7 +454,11 @@ class ExpectObj extends Assert { * element for which $element == $needle. * Note: If $needle is an object, === will be used. */ - public function toNotContain(TVal $expected, string $msg = '', mixed ...$args): void where T as Traversable { + public function toNotContain( + TVal $expected, + string $msg = '', + mixed ...$args + ): void where T as Traversable { $msg = \vsprintf($msg, $args); $this->assertNotContains($expected, not_hack_array($this->var), $msg); } @@ -462,7 +466,11 @@ class ExpectObj extends Assert { /** * Assert: $actual does not contain the substring $expected */ - public function toNotContainSubstring(string $expected, string $msg = '', mixed ...$args): void where T = string { + public function toNotContainSubstring( + string $expected, + string $msg = '', + mixed ...$args + ): void where T = string { $msg = \vsprintf($msg, $args); $this->assertNotContains($expected, not_hack_array($this->var), $msg); } @@ -471,7 +479,11 @@ class ExpectObj extends Assert { * Assert: That the KeyedTraversible $key has a key set. * Note: If $key is a Set, use assertContains. */ - public function toNotContainKey(TKey $key, string $msg = '', mixed ...$args): void where T as KeyedContainer { + public function toNotContainKey( + TKey $key, + string $msg = '', + mixed ...$args + ): void where T as KeyedContainer { $msg = \vsprintf($msg, $args); $obj = $this->var; $this->assertFalse(\array_key_exists($key, $obj), $msg); diff --git a/src/utils.hack b/src/utils.hack index 2188d63..d308493 100644 --- a/src/utils.hack +++ b/src/utils.hack @@ -34,7 +34,8 @@ function print_type(mixed $value): string { } function is_iterable(mixed $value): bool { - return \is_array($value) || (\is_object($value) && ($value is Traversable<_>)); + return \is_array($value) || + (\is_object($value) && ($value is Traversable<_>)); } function is_type(mixed $value): bool { diff --git a/tests/ExpectObjTest.hack b/tests/ExpectObjTest.hack index d7fbb51..2124178 100644 --- a/tests/ExpectObjTest.hack +++ b/tests/ExpectObjTest.hack @@ -216,21 +216,23 @@ final class ExpectObjTest extends HackTest { expect(() ==> $rm->invokeArgs($obj, varray['custom msg'])) ->toThrow(ExpectationFailedException::class, 'custom msg'); } else { - expect(() ==> $rm->invokeArgs($obj, varray[$expected, 'custom msg']))->toThrow( - ExpectationFailedException::class, - 'custom msg', - ); + expect(() ==> $rm->invokeArgs($obj, varray[$expected, 'custom msg'])) + ->toThrow(ExpectationFailedException::class, 'custom msg'); ; } // And with funky sprintfification if ($expected === self::EMPTY_VALUE) { - expect(() ==> $rm->invokeArgs($obj, varray['custom %s %d %f', 'msg', 1, 2.1])) + expect( + () ==> $rm->invokeArgs($obj, varray['custom %s %d %f', 'msg', 1, 2.1]), + ) ->toThrow(ExpectationFailedException::class, 'custom msg 1 2.1'); } else { expect( - () ==> - $rm->invokeArgs($obj, varray[$expected, 'custom %s %d %f', 'msg', 1, 2.1]), + () ==> $rm->invokeArgs( + $obj, + varray[$expected, 'custom %s %d %f', 'msg', 1, 2.1], + ), )->toThrow(ExpectationFailedException::class, 'custom msg 1 2.1'); } } @@ -449,7 +451,9 @@ final class ExpectObjTest extends HackTest { } public function testToThrowReturnsException(): void { - $e = expect(() ==> { throw new \Exception("Hello, world"); })->toThrow(\Exception::class); + $e = expect(() ==> { + throw new \Exception("Hello, world"); + })->toThrow(\Exception::class); expect($e->getMessage())->toContainSubstring('Hello, world'); } }