Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions types/Support/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

function testThrowIf(float|int $foo, ?DateTime $bar = null): void
{
assertType('never', throw_if(true, Exception::class));
rescue(fn () => assertType('never', throw_if(true, Exception::class)));
assertType('false', throw_if(false, Exception::class));
assertType('false', throw_if(empty($foo)));
throw_if(is_float($foo));
Expand All @@ -56,13 +56,13 @@ function testThrowIf(float|int $foo, ?DateTime $bar = null): void
assertType('null', $bar);
assertType('null', throw_if(null, Exception::class));
assertType("''", throw_if('', Exception::class));
assertType('never', throw_if('foo', Exception::class));
rescue(fn () => assertType('never', throw_if('foo', Exception::class)));
}

function testThrowUnless(float|int $foo, ?DateTime $bar = null): void
{
assertType('true', throw_unless(true, Exception::class));
assertType('never', throw_unless(false, Exception::class));
rescue(fn () => assertType('never', throw_unless(false, Exception::class)));
assertType('true', throw_unless(empty($foo)));
throw_unless(is_int($foo));
assertType('int', $foo);
Expand All @@ -72,8 +72,8 @@ function testThrowUnless(float|int $foo, ?DateTime $bar = null): void
assertType('DateTime', $bar);

// Truthy/falsey argument
assertType('never', throw_unless(null, Exception::class));
assertType('never', throw_unless('', Exception::class));
rescue(fn () => assertType('never', throw_unless(null, Exception::class)));
rescue(fn () => assertType('never', throw_unless('', Exception::class)));
assertType("'foo'", throw_unless('foo', Exception::class));
}

Expand Down