-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
Bug report
With the recent commits now it's possible to give variable literal values that it can hold. For example /** @var 0|1 $foo */ means $foo can only be 0 or 1. I don't know if this was intentional or was a side effect of something else. But it seems it's working.
But when a value that is out of the expected values is given, the error message is unclear.
Code snippet that reproduces the problem
<?php declare(strict_types = 1);
class HelloWorld
{
/** @var 0|1 $foo */
public $foo;
public function foo(): void
{
$this->foo = 2;
}
}https://phpstan.org/r/b58a5065-812b-4a3f-9e3d-2f79fb788f6d
Expected output
The error message Property HelloWorld::$foo (int) does not accept int. is not clear. Maybe it could be improved with Property HelloWorld::$foo (int(0)|int(1)) does not accept int(2).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels