|
41 | 41 | }));
|
42 | 42 | assertType('Illuminate\Support\HigherOrderTapProxy', tap(new User()));
|
43 | 43 |
|
44 |
| -assertType('bool', throw_if(true, Exception::class)); |
| 44 | +function testThrowIf(float|int $foo): void |
| 45 | +{ |
| 46 | + assertType('never', throw_if(true, Exception::class)); |
| 47 | + assertType('bool', throw_if(false, Exception::class)); |
| 48 | + assertType('false', throw_if(empty($foo))); |
| 49 | + throw_if(is_float($foo)); |
| 50 | + assertType('int', $foo); |
| 51 | + throw_if($foo == false); |
| 52 | + assertType('int<min, -1>|int<1, max>', $foo); |
| 53 | +} |
45 | 54 |
|
46 |
| -assertType('bool', throw_unless(true, Exception::class)); |
| 55 | +function testThrowUnless(float|int $foo): void |
| 56 | +{ |
| 57 | + assertType('bool', throw_unless(true, Exception::class)); |
| 58 | + assertType('never', throw_unless(false, Exception::class)); |
| 59 | + assertType('true', throw_unless(empty($foo))); |
| 60 | + throw_unless(is_int($foo)); |
| 61 | + assertType('int', $foo); |
| 62 | + throw_unless($foo == false); |
| 63 | + assertType('0', $foo); |
| 64 | +} |
47 | 65 |
|
48 | 66 | assertType('int', transform('filled', fn () => 1, true));
|
49 | 67 | assertType('int', transform(['filled'], fn () => 1));
|
|
0 commit comments