-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
Bug report
Code snippet that reproduces the problem
class Foo
{
/**
* @return array{foo?: string, bar?: string}
*/
private function docBlock(int $a) : array
{
$docs = [];
if ($a < 10) {
$docs['foo'] = 's';
}
if ($a < 100) {
$docs['bar'] = 'm';
}
return $docs;
}
}https://phpstan.org/r/f6bd1c14-ad32-4263-8dd2-6f20e6344a86
This error was produced as follows.
Method Foo::docBlock() should return array()|array('foo' => string, 'bar' => string) but returns array(?'foo' => 's', ?'bar' => 'm').
It works fine with a single array-key.
https://phpstan.org/r/5255b43c-283b-4085-bea7-862f9484ae57
Expected output
No error.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels