Skip to content

Commit 25f307f

Browse files
Fix
1 parent 0e8ab9c commit 25f307f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tests/PHPStan/Analyser/nsrt/throw-points/php8/null-safe-method-call.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,19 @@ function () {
4848
}
4949
};
5050

51+
/**
52+
* @return object
53+
* @throws void
54+
*/
55+
function notNullableDoesntThrow(...$args)
56+
{
57+
}
58+
5159
function () {
52-
$result = doesntThrow();
53-
if ($result === null) {
54-
return;
55-
}
56-
// $result is mixed~null, so ?-> never short-circuits
5760
try {
58-
$result?->{$foo = 1}($bar = 2);
61+
notNullableDoesntThrow()?->{$foo = 1}($bar = 2);
5962
} finally {
63+
// doesntThrow() does not return null, so ?-> will not short-circuit
6064
assertVariableCertainty(TrinaryLogic::createYes(), $foo);
6165
assertVariableCertainty(TrinaryLogic::createYes(), $bar);
6266
}

0 commit comments

Comments
 (0)