-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
phpstan/phpstan-src
#3036Closed
Copy link
Labels
Milestone
Description
Bug report
The following simple code produces strange error: "Default value of the parameter #1 $value (array{NAN}) of method HelloWorld::test() is incompatible with type array{NAN}|int."
class HelloWorld
{
const DEFAULT_VALUE = [NAN]; // meta unique value, distinct from anything, but equal to itself. Means: use default value
/**
* @param int|self::DEFAULT_VALUE $value
*/
public function test (mixed $value = self::DEFAULT_VALUE) {
if ($value === self::DEFAULT_VALUE) {
echo 'default';
} else {
echo (int) $value;
}
}
}It seems like it's not possible to specify class constant as type alternative in type union if class constant evaluates to array with NAN/s, though any PHP value must be equal to itself.
Code snippet that reproduces the problem
https://phpstan.org/r/e7839a10-d70e-4dba-a05d-f01e82759c3a
Expected output
No error
Did PHPStan help you today? Did it make you happy in any way?
No response
Reactions are currently unavailable