1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix exhaustiveness checks for const value

This commit is contained in:
Brown 2020-08-31 23:23:24 -04:00 committed by Daniil Gentili
parent 47c1d15afd
commit 8611f99e09
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 26 additions and 2 deletions

View File

@ -143,15 +143,17 @@ class MatchAnalyzer
throw new \UnexpectedValueException('bad');
}
$all_conds = array_merge($arm->conds, $all_conds);
$all_conds = \array_merge($arm->conds, $all_conds);
}
$all_match_condition = self::convertCondsToConditional(
array_values($all_conds),
\array_values($all_conds),
$match_condition,
$match_condition->getAttributes()
);
ExpressionAnalyzer::analyze($statements_analyzer, $all_match_condition, $context);
$clauses = \Psalm\Type\Algebra::getFormula(
\spl_object_id($all_match_condition),
\spl_object_id($all_match_condition),

View File

@ -141,6 +141,28 @@ class MatchTest extends TestCase
false,
'8.0',
],
'notAllConstEnumsMet' => [
'<?php
class Airport {
const JFK = "jfk";
const LHR = "lhr";
const LGA = "lga";
/**
* @param self::* $airport
*/
public static function getName(string $airport): string {
return match ($airport) {
self::JFK => "John F Kennedy Airport",
self::LHR => "London Heathrow",
};
}
}',
'error_message' => 'UnhandledMatchCondition',
[],
false,
'8.0',
],
];
}
}