@Sergiu17 no errors, given I have this sample code:
class Test
{
public string $type;
}
function getTest(): Test
{
$test = new Test();
$test->type = 'test';
return $test;
}
$a = match (getTest()->type) {
'test' => 'value',
};
when running phpstan on this code, it says Match expression does not handle remaining value: string. And I actually want some exception to be thrown, when I don't handle that case(which php does that), but phpstan does not allow that, so what I did to solve that phpstan error:
$a = match (getTest()->type) {
'test' => 'value',
default => throw new Exception('not handled case');
};
so I was curious about that, can I make a function like unreachable() and tell phpstan that this will always throw exception, because if I define the function like this and use that in default case:
/** @throws Exception */
function unreachable(): void
{
throw new Exception('test');
}
it will consider the type of $a variable to be string|void, but that is not the case when throwing directly in default case.