mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Prevent duplicate switch return types
This commit is contained in:
parent
ea08e0c613
commit
c17bacd682
@ -268,7 +268,7 @@ class ScopeAnalyzer
|
||||
}
|
||||
|
||||
if ($has_default_terminator || isset($stmt->allMatched)) {
|
||||
return array_merge($control_actions, [self::ACTION_END]);
|
||||
return \array_values(array_unique(array_merge($control_actions, [self::ACTION_END])));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -984,6 +984,21 @@ class SwitchTypeTest extends TestCase
|
||||
return true;
|
||||
}'
|
||||
],
|
||||
'alwaysReturnsWithConditionalReturnFirst' => [
|
||||
'<?php
|
||||
function getRows(string $s) : int {
|
||||
if (rand(0, 1)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
switch ($s) {
|
||||
case "a":
|
||||
return 2;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user