1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix #4516 - treat exit() as the empty type

This commit is contained in:
Matt Brown 2020-11-09 08:44:03 -05:00 committed by Daniil Gentili
parent ec9d8e6700
commit 9fd4a24c55
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 19 additions and 0 deletions

View File

@ -78,6 +78,8 @@ class ExitAnalyzer
$context->inside_call = false;
}
$statements_analyzer->node_data->setType($stmt, \Psalm\Type::getEmpty());
return true;
}
}

View File

@ -188,6 +188,23 @@ class MatchTest extends TestCase
false,
'8.0',
],
'exitIsLikeThrow' => [
'<?php
/**
* @param 1|2|3 $i
*/
function foo(int $i): void {
$a = match ($i) {
1 => exit(),
2, 3 => $i,
};
$a === "aaa";
}',
'error_message' => 'DocblockTypeContradiction',
[],
false,
'8.0',
],
];
}
}