-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
phpstan/phpstan-src
#1941Labels
Milestone
Description
Bug report
I have an array ['html' => null, 'htmlsource' => null, 'txt' => null, 'raw' => null, 'eml' => null] of type array{html: ?string, htmlsource: ?string, txt: ?string, raw: ?string, eml: ?string}.
I'm trying to change $array[$format] value (where $format is either html, htmlsource, txt, raw, or eml), but PHPStan is throwing error Array (array<string, string|null>) does not accept key string..
There is also another error Method Message::getBody() should return string but returns string|null.. I don't know if it's related, but this is super weird since I assign a string to $this->body[$format] if it's equals to null.
Code snippet that reproduces the problem
https://phpstan.org/r/ec4cb784-4886-4bb8-83b8-e034fd042f55
Expected output
The static analytics should not claim the two errors.
Thanks!
Reactions are currently unavailable