Skip to content

Commit 3319568

Browse files
authored
[12.x] Fix PHPStan Integrations (#56369)
* [12.x] Fix PHPStan Static code tests now throws the actual exception, using rescue() prevents this: phpstan/phpstan#13290 Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> --------- Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
1 parent c82b43b commit 3319568

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

types/Support/Helpers.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
function testThrowIf(float|int $foo, ?DateTime $bar = null): void
4545
{
46-
assertType('never', throw_if(true, Exception::class));
46+
rescue(fn () => assertType('never', throw_if(true, Exception::class)));
4747
assertType('false', throw_if(false, Exception::class));
4848
assertType('false', throw_if(empty($foo)));
4949
throw_if(is_float($foo));
@@ -56,13 +56,13 @@ function testThrowIf(float|int $foo, ?DateTime $bar = null): void
5656
assertType('null', $bar);
5757
assertType('null', throw_if(null, Exception::class));
5858
assertType("''", throw_if('', Exception::class));
59-
assertType('never', throw_if('foo', Exception::class));
59+
rescue(fn () => assertType('never', throw_if('foo', Exception::class)));
6060
}
6161

6262
function testThrowUnless(float|int $foo, ?DateTime $bar = null): void
6363
{
6464
assertType('true', throw_unless(true, Exception::class));
65-
assertType('never', throw_unless(false, Exception::class));
65+
rescue(fn () => assertType('never', throw_unless(false, Exception::class)));
6666
assertType('true', throw_unless(empty($foo)));
6767
throw_unless(is_int($foo));
6868
assertType('int', $foo);
@@ -72,8 +72,8 @@ function testThrowUnless(float|int $foo, ?DateTime $bar = null): void
7272
assertType('DateTime', $bar);
7373

7474
// Truthy/falsey argument
75-
assertType('never', throw_unless(null, Exception::class));
76-
assertType('never', throw_unless('', Exception::class));
75+
rescue(fn () => assertType('never', throw_unless(null, Exception::class)));
76+
rescue(fn () => assertType('never', throw_unless('', Exception::class)));
7777
assertType("'foo'", throw_unless('foo', Exception::class));
7878
}
7979

0 commit comments

Comments
 (0)