-
Notifications
You must be signed in to change notification settings - Fork 668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore finally block in try catch #11170
Comments
Hey @bless-rng, can you reproduce the issue on https://psalm.dev? These will be used as phpunit tests when implementing the feature or fixing this bug. |
|
I found these snippets: https://psalm.dev/r/a8595a9c94<?php
function test(int $a, int $b): int {
try {
$c = (int)($a / $b);
} catch(Throwable $t) {
$c = null;
} finally {
$c = 1;
}
return $c;
}
|
Also i found more cases.
|
I found these snippets: https://psalm.dev/r/a08800bdf5<?php
function test(string $s): string {
try {
switch ($s){
case "GOOD WORD":
$x = 'GOOD';
break;
case "BAD WORD":
$x = 'BAD';
break;
default:
$x = 'UNKNOWN';
}
} catch(Throwable $t) {
$x = 'EMPTY';
}
return $x;
}
https://psalm.dev/r/51ce75c690<?php
function test(string $s): string {
switch ($s){
case "GOOD WORD":
$x = 'GOOD';
break;
case "BAD WORD":
$x = 'BAD';
break;
default:
$x = 'UNKNOWN';
}
return $x;
}
https://psalm.dev/r/c63ea0be0f<?php
function test(string $s): string {
try {
if ($s === 'GOOD WORD') {
$x = 'GOOD';
} elseif ($s === 'BAD WORD') {
$x = 'BAD';
} else {
$x = 'UNKNOWN';
}
} catch(Throwable $t) {
$x = 'EMPTY';
}
return $x;
}
|
When i use
finally
where i setup variable as not nullable - psalm still null possible errorThe text was updated successfully, but these errors were encountered: