Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit eb36e64

Browse files
committed
hackfmt
1 parent b01e21a commit eb36e64

File tree

4 files changed

+36
-16
lines changed

4 files changed

+36
-16
lines changed

src/Constraint/IsType.hack

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ class IsType {
3030
'array' => ($x ==> \is_array($x)),
3131
'object' => ($x ==> \is_object($x)),
3232
'resource' => (
33-
$x ==> ($x is resource) || (
34-
@\get_resource_type(/* HH_FIXME[4110] closed resources fail is resource */ $x) is string
35-
)
33+
$x ==> ($x is resource) ||
34+
(
35+
@\get_resource_type(
36+
/* HH_FIXME[4110] closed resources fail is resource */ $x,
37+
) is string
38+
)
3639
),
3740
'scalar' => ($x ==> \is_scalar($x)),
3841
'callable' => ($x ==> \is_callable($x)),

src/ExpectObj.hack

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class ExpectObj<T> extends Assert {
234234
TVal $needle,
235235
string $msg = '',
236236
mixed ...$args
237-
): void where T as Traversable<TVal>{
237+
): void where T as Traversable<TVal> {
238238
$msg = \vsprintf($msg, $args);
239239
$this->assertContains($needle, not_hack_array($this->var), $msg);
240240
}
@@ -454,15 +454,23 @@ class ExpectObj<T> extends Assert {
454454
* element for which $element == $needle.
455455
* Note: If $needle is an object, === will be used.
456456
*/
457-
public function toNotContain<TVal>(TVal $expected, string $msg = '', mixed ...$args): void where T as Traversable<TVal> {
457+
public function toNotContain<TVal>(
458+
TVal $expected,
459+
string $msg = '',
460+
mixed ...$args
461+
): void where T as Traversable<TVal> {
458462
$msg = \vsprintf($msg, $args);
459463
$this->assertNotContains($expected, not_hack_array($this->var), $msg);
460464
}
461465

462466
/**
463467
* Assert: $actual does not contain the substring $expected
464468
*/
465-
public function toNotContainSubstring(string $expected, string $msg = '', mixed ...$args): void where T = string {
469+
public function toNotContainSubstring(
470+
string $expected,
471+
string $msg = '',
472+
mixed ...$args
473+
): void where T = string {
466474
$msg = \vsprintf($msg, $args);
467475
$this->assertNotContains($expected, not_hack_array($this->var), $msg);
468476
}
@@ -471,7 +479,11 @@ class ExpectObj<T> extends Assert {
471479
* Assert: That the KeyedTraversible $key has a key set.
472480
* Note: If $key is a Set, use assertContains.
473481
*/
474-
public function toNotContainKey<TKey as arraykey, TVal>(TKey $key, string $msg = '', mixed ...$args): void where T as KeyedContainer<TKey, TVal> {
482+
public function toNotContainKey<TKey as arraykey, TVal>(
483+
TKey $key,
484+
string $msg = '',
485+
mixed ...$args
486+
): void where T as KeyedContainer<TKey, TVal> {
475487
$msg = \vsprintf($msg, $args);
476488
$obj = $this->var;
477489
$this->assertFalse(\array_key_exists($key, $obj), $msg);

src/utils.hack

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ function print_type(mixed $value): string {
3434
}
3535

3636
function is_iterable(mixed $value): bool {
37-
return \is_array($value) || (\is_object($value) && ($value is Traversable<_>));
37+
return \is_array($value) ||
38+
(\is_object($value) && ($value is Traversable<_>));
3839
}
3940

4041
function is_type(mixed $value): bool {

tests/ExpectObjTest.hack

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,21 +216,23 @@ final class ExpectObjTest extends HackTest {
216216
expect(() ==> $rm->invokeArgs($obj, varray['custom msg']))
217217
->toThrow(ExpectationFailedException::class, 'custom msg');
218218
} else {
219-
expect(() ==> $rm->invokeArgs($obj, varray[$expected, 'custom msg']))->toThrow(
220-
ExpectationFailedException::class,
221-
'custom msg',
222-
);
219+
expect(() ==> $rm->invokeArgs($obj, varray[$expected, 'custom msg']))
220+
->toThrow(ExpectationFailedException::class, 'custom msg');
223221
;
224222
}
225223

226224
// And with funky sprintfification
227225
if ($expected === self::EMPTY_VALUE) {
228-
expect(() ==> $rm->invokeArgs($obj, varray['custom %s %d %f', 'msg', 1, 2.1]))
226+
expect(
227+
() ==> $rm->invokeArgs($obj, varray['custom %s %d %f', 'msg', 1, 2.1]),
228+
)
229229
->toThrow(ExpectationFailedException::class, 'custom msg 1 2.1');
230230
} else {
231231
expect(
232-
() ==>
233-
$rm->invokeArgs($obj, varray[$expected, 'custom %s %d %f', 'msg', 1, 2.1]),
232+
() ==> $rm->invokeArgs(
233+
$obj,
234+
varray[$expected, 'custom %s %d %f', 'msg', 1, 2.1],
235+
),
234236
)->toThrow(ExpectationFailedException::class, 'custom msg 1 2.1');
235237
}
236238
}
@@ -449,7 +451,9 @@ final class ExpectObjTest extends HackTest {
449451
}
450452

451453
public function testToThrowReturnsException(): void {
452-
$e = expect(() ==> { throw new \Exception("Hello, world"); })->toThrow(\Exception::class);
454+
$e = expect(() ==> {
455+
throw new \Exception("Hello, world");
456+
})->toThrow(\Exception::class);
453457
expect($e->getMessage())->toContainSubstring('Hello, world');
454458
}
455459
}

0 commit comments

Comments
 (0)