mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Search in while & try/catch
This commit is contained in:
parent
2b8c95a19d
commit
162a8a2c2b
@ -24,6 +24,7 @@ class ScopeChecker
|
|||||||
|
|
||||||
if ($stmt instanceof PhpParser\Node\Stmt\Return_ ||
|
if ($stmt instanceof PhpParser\Node\Stmt\Return_ ||
|
||||||
$stmt instanceof PhpParser\Node\Stmt\Throw_ ||
|
$stmt instanceof PhpParser\Node\Stmt\Throw_ ||
|
||||||
|
$stmt instanceof PhpParser\Node\Expr\Exit_ ||
|
||||||
($check_continue && $stmt instanceof PhpParser\Node\Stmt\Continue_) ||
|
($check_continue && $stmt instanceof PhpParser\Node\Stmt\Continue_) ||
|
||||||
($check_break && $stmt instanceof PhpParser\Node\Stmt\Break_)) {
|
($check_break && $stmt instanceof PhpParser\Node\Stmt\Break_)) {
|
||||||
|
|
||||||
@ -131,7 +132,10 @@ class ScopeChecker
|
|||||||
for ($i = count($stmts) - 1; $i >= 0; $i--) {
|
for ($i = count($stmts) - 1; $i >= 0; $i--) {
|
||||||
$stmt = $stmts[$i];
|
$stmt = $stmts[$i];
|
||||||
|
|
||||||
if ($stmt instanceof PhpParser\Node\Stmt\Return_ || $stmt instanceof PhpParser\Node\Stmt\Throw_) {
|
if ($stmt instanceof PhpParser\Node\Stmt\Return_ ||
|
||||||
|
$stmt instanceof PhpParser\Node\Stmt\Throw_ ||
|
||||||
|
$stmt instanceof PhpParser\Node\Expr\Exit_
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,6 +180,24 @@ class ScopeChecker
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($stmt instanceof PhpParser\Node\Stmt\While_) {
|
||||||
|
if (self::doesReturnOrThrow($stmt->stmts)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($stmt instanceof PhpParser\Node\Stmt\TryCatch) {
|
||||||
|
if (self::doesReturnOrThrow($stmt->stmts)) {
|
||||||
|
foreach ($stmt->catches as $catch) {
|
||||||
|
if (!self::doesReturnOrThrow($catch->stmts)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($stmt instanceof PhpParser\Node\Stmt\Nop) {
|
if ($stmt instanceof PhpParser\Node\Stmt\Nop) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user