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

Fix #3779 - allow ParadoxicalCondition of default to be suppressed

This commit is contained in:
Brown 2020-07-08 14:51:20 -04:00
parent 33a834bb0b
commit bf7bcc0dca
2 changed files with 16 additions and 1 deletions

View File

@ -499,7 +499,8 @@ class SwitchCaseAnalyzer
new ParadoxicalCondition(
'All possible case statements have been met, default is impossible here',
new CodeLocation($statements_analyzer->getSource(), $case)
)
),
$statements_analyzer->getSuppressedIssues()
)) {
return false;
}

View File

@ -923,6 +923,20 @@ class SwitchTypeTest extends TestCase
return 4;
}'
],
'suppressParadox' => [
'<?php
/** @psalm-var 1|2|3 $i */
$i = rand(1, 3);
/** @psalm-suppress ParadoxicalCondition */
switch($i) {
case 1: break;
case 2: break;
case 3: break;
default:
echo "bar";
}'
],
];
}