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:
parent
47c1d15afd
commit
8611f99e09
@ -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),
|
||||
|
@ -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',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user