Skip to content

Commit

Permalink
Fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Sep 1, 2020
1 parent 9404597 commit 3cdb13f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,21 @@ public static function analyze(
$statements_analyzer->removeSuppressedIssues(['RedundantConditionGivenDocblockType']);
}

if ($switch_var_id) {
if ($switch_var_id && $last_arm->conds) {
$codebase = $statements_analyzer->getCodebase();

$all_conds = $last_arm->conds ?: [];
$all_conds = $last_arm->conds;

foreach ($arms as $arm) {
if (!$arm->conds) {
throw new \UnexpectedValueException('bad');
}

$all_conds = array_merge($arm->conds, $all_conds);
}

$all_match_condition = self::convertCondsToConditional(
$all_conds,
array_values($all_conds),
$match_condition,
$match_condition->getAttributes()
);
Expand Down
8 changes: 8 additions & 0 deletions src/Psalm/Issue/UnhandledMatchCondition.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
namespace Psalm\Issue;

class UnhandledMatchCondition extends CodeIssue
{
const ERROR_LEVEL = 7;
const SHORTCODE = 236;
}
2 changes: 1 addition & 1 deletion tests/MatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function foo(string $foo): string {
"foo" => "foo",
};
}',
'error_message' => 'ParadoxicalCondition',
'error_message' => 'UnhandledMatchCondition',
[],
false,
'8.0',
Expand Down

0 comments on commit 3cdb13f

Please sign in to comment.