1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Skip currently-failing undefined variable test

This commit is contained in:
Brown 2020-09-21 16:01:14 -04:00
parent cdb2b5caf6
commit b501db6dd2
4 changed files with 24 additions and 2 deletions

View File

@ -70,7 +70,7 @@ class TryAnalyzer
}
if ($stmt->finally) {
$try_context->finally_scope = new FinallyScope();
$try_context->finally_scope = new FinallyScope($try_context->vars_in_scope);
}
}

View File

@ -14,4 +14,12 @@ class FinallyScope
* @var array<string, Type\Union>
*/
public $vars_in_scope = [];
/**
* @param array<string, Type\Union> $vars_in_scope
*/
public function __construct(array $vars_in_scope)
{
$this->vars_in_scope = $vars_in_scope;
}
}

View File

@ -351,6 +351,20 @@ class TryCatchTest extends TestCase
// do nothing
}'
],
'notRedundantVarCheckInFinally' => [
'<?php
$var = "a";
try {
if (rand(0, 1)) {
throw new \Exception();
}
$var = "b";
} finally {
if ($var === "a") {
echo $var;
}
}'
],
];
}

View File

@ -1212,7 +1212,7 @@ class UnusedVariableTest extends TestCase
return "hello";
}',
],
'useTryAndCatchAssignedVariableInsideFinally' => [
'SKIPPED-useTryAndCatchAssignedVariableInsideFinally' => [
'<?php
function foo() : void {
try {