Skip to content
Permalink
Browse files

Fix #1580 - look for no-returns in try/catch statements

  • Loading branch information...
muglug committed May 15, 2019
1 parent 7f4173e commit 1c10ae11bfd605c21dddb96b985030c0901cc7e7
@@ -291,6 +291,13 @@ function ($fq_catch_class) use ($codebase) {
$statements_analyzer->analyze($catch->stmts, $catch_context);
// recalculate in case there's a no-return clause
$catch_actions[$i] = ScopeAnalyzer::getFinalControlActions(
$catch->stmts,
$codebase->config->exit_functions,
$context->inside_case
);
foreach ($issues_to_suppress as $issue_to_suppress) {
if (!in_array($issue_to_suppress, $suppressed_issues, true)) {
$statements_analyzer->removeSuppressedIssues([$issue_to_suppress]);
@@ -563,7 +563,7 @@ public function foo() {
class B extends A {
/**
* @return no-return
* @return never-returns
*/
public function foo() {
exit();
@@ -205,6 +205,22 @@ function doTry() : void {
}
}',
],
'noReturnInsideCatch' => [
'<?php
/**
* @return never-returns
*/
function example() : void {
throw new Exception();
}
try {
$str = "a";
} catch (Exception $e) {
example();
}
ord($str);'
],
];
}

0 comments on commit 1c10ae1

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