-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
phpstan/phpstan-src
#4300Labels
Description
Bug report
I have code looking something like that:
<?php declare(strict_types = 1);
$map = [
'datetime' => \DateTime::class,
'stdclass' => \stdClass::class,
];
$settings = json_decode('{"class": "datetim"}');
new ($map[$settings->class])();What is weird in this example, is that PHPStan does not show any error. I am not saying it should automatically recognize the type of the json_decode call, but $settings->class is of type mixed, and it is not said that $map[$settings->class] returns a proper class string.
Code snippet that reproduces the problem
https://phpstan.org/r/dd0caadd-0d1a-43c7-b6bc-480923a25b9f
Expected output
I would have expected that PHPStan warns me in line 13 of the example, since it is not guaranteed that this will be working.
Did PHPStan help you today? Did it make you happy in any way?
All the time :-)
Reactions are currently unavailable