mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Suppress enum redundant conditions too
This commit is contained in:
parent
3805893c5a
commit
19ca1c9311
@ -278,6 +278,10 @@ class SwitchChecker
|
||||
$statements_checker->addSuppressedIssues(['RedundantCondition']);
|
||||
}
|
||||
|
||||
if (!in_array('RedundantConditionGivenDocblockType', $suppressed_issues, true)) {
|
||||
$statements_checker->addSuppressedIssues(['RedundantConditionGivenDocblockType']);
|
||||
}
|
||||
|
||||
$case_vars_in_scope_reconciled =
|
||||
Reconciler::reconcileKeyedTypes(
|
||||
$reconcilable_if_types,
|
||||
@ -297,6 +301,10 @@ class SwitchChecker
|
||||
$statements_checker->removeSuppressedIssues(['RedundantCondition']);
|
||||
}
|
||||
|
||||
if (!in_array('RedundantConditionGivenDocblockType', $suppressed_issues, true)) {
|
||||
$statements_checker->removeSuppressedIssues(['RedundantConditionGivenDocblockType']);
|
||||
}
|
||||
|
||||
$case_context->vars_in_scope = $case_vars_in_scope_reconciled;
|
||||
foreach ($reconcilable_if_types as $var_id => $_) {
|
||||
$case_context->vars_possibly_in_scope[$var_id] = true;
|
||||
|
@ -35,6 +35,20 @@ class EnumTest extends TestCase
|
||||
foo(2);
|
||||
foo(3);',
|
||||
],
|
||||
'noRedundantConditionWithSwitch' => [
|
||||
'<?php
|
||||
/**
|
||||
* @psalm-param ( "foo" | "bar") $s
|
||||
*/
|
||||
function foo(string $s) : void {
|
||||
switch ($s) {
|
||||
case "foo":
|
||||
break;
|
||||
case "bar":
|
||||
break;
|
||||
}
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user