Creating new array on mixed[] should be allowed if key does not exist.
Bug report
mixed[] type actually allows to have a multidimensional array if the key is not set.
Code snippet that reproduces the problem
/** * @param mixed[] $values * @return mixed[] */ function apply(array $values): array { if (!array_key_exists('key', $values)) { $values['key'][] = 'any'; } return $values; }
https://phpstan.org/r/587e0c33-7144-4bcc-aa96-e284d2a53ab3
Expected output
No error.
Did PHPStan help you today? Did it make you happy in any way?
Thanks all involved people for such a great tool. Especially for this latest one i've got!
https://phpstan.org/r/3d7adc9b-8ea4-4cd8-bada-b5117e57211d