Skip to content
Permalink
Browse files

Properly fix #1128 with additional check

  • Loading branch information...
muglug committed May 20, 2019
1 parent 83a2122 commit 2637156f458420ebc351c1e32f58824faf804d93
Showing with 21 additions and 1 deletion.
  1. +1 −1 src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php
  2. +20 −0 tests/UnusedVariableTest.php
@@ -51,7 +51,7 @@ public static function analyze(
*/
$context->possibly_thrown_exceptions = [];
if ($all_catches_leave) {
if ($all_catches_leave && !$stmt->finally) {
$try_context = $context;
} else {
$try_context = clone $context;
@@ -965,6 +965,26 @@ function foo() : void {
}
}'
],
'useTryAssignedVariableInFinallyWhenCatchExits' => [
'<?php
/**
* @return resource
*/
function getStream() {
throw new \Exception();
}
$stream = null;
try {
$stream = getStream();
\file_put_contents("./foobar", $stream);
} catch (\Exception $e) {
throw new \Exception("Something went wrong");
} finally {
\fclose($stream);
}',
],
];
}

0 comments on commit 2637156

Please sign in to comment.
You can’t perform that action at this time.