-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Labels
Milestone
Description
Hi, I have a function which returns an array but phpstan says, it returns null
Method Test::test() should return array but returns null.
This is the code:
class Test {
private $answersOrder = [];
public function test(string $qId): array
{
if (null !== $this->answersOrder[$qId]) {
return $this->answersOrder[$qId];
}
$this->answersOrder[$qId] = 5;
return $this->answersOrder[$qId];
}
}
As you can see it always returns an array. I think that first IF block confuses phpstan somehow
Expected output
There shouldnt be any error for that class
Reactions are currently unavailable