-
-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Labels
Description
Hi folks,
I get the following issue with MathUtilityTypeSpecifyingExtension.
function foo(string $value)
{
// At this point phpstan properly assumes that $value is string
if (MathUtility::canBeInterpretedAsInteger($value)) {
return (int)$value;
}
// At this point phpstan falsely assumes that $value is numeric-string and throws errors in the following match statement.
return match ($value) {
'' => null,
'true' => true,
'false' => false,
default => $value,
};
}It seems like whenever MathUtility::canBeInterpretedAsInteger() is called on a variable, it's type is changed to numeric-string no matter the outcome.
------ ------------------------------------------------------------------------------
55 Dumped type: string
61 Dumped type: numeric-string
64 Match arm comparison between numeric-string and '' is always false.
65 Match arm comparison between numeric-string and 'true' is always false.
66 Match arm comparison between numeric-string and 'false' is always false.
------ ------------------------------------------------------------------------------