-
-
Notifications
You must be signed in to change notification settings - Fork 947
PHPStan thinks static variable can be float #1870
Copy link
Copy link
Closed
Labels
Milestone
Description
PHPStan 0.11
Summary of a problem or a feature request
I don't understand this one. Making a local static variable makes PHPStan think the variable can be a float when there's really no reason to. Removing the static removes the error.
Code snippet that reproduces the problem
function returnsInt(): int
{
static $i = 0;
return ++$i;
}Function returnsInt() should return int but returns float|int.
https://phpstan.org/r/249d5f01-7caf-406d-bf12-5f6b116c3810
Expected output
No error.
Reactions are currently unavailable