Bug report
When spreading an associative array into a function or method call the type of a generic optional argument may be unexpectedly restricted to its default value.
Code snippet that reproduces the problem
https://phpstan.org/r/8954c7b1-5966-4015-9e6e-59054cb17c1e
Expected output
Passing any value fitting the template bound should be valid - just like when there is no preceding required argument: https://phpstan.org/r/4a4250d2-ab86-47d5-ad1f-cde664d47281.
Did PHPStan help you today? Did it make you happy in any way?
Yes, for sure!
We at @sport-iat heavily rely on PHPStan to statically validate our code against self-generated array shape typedefs (from JSON schema definitions) together with @opis/json-schema for validation at runtime. So a big thanks to everyone involved in this great project!
Currently, I'm trying to figure out if/how generated DTO-like classes could replace our array shapes with the help of advanced hydration/normalization techniques as provided by i.e. @CuyZ/Valinor. Thats actually why I discovered the unexpected behavior for generic class constructors having optional arguments: https://phpstan.org/r/1e4a2a1d-2beb-46d8-809c-6fdc631efd33.