graphql-php icon indicating copy to clipboard operation
graphql-php copied to clipboard

PHPStan > `iterable<string, mixed>` removes all other type safety

Open ruudk opened this issue 2 years ago • 1 comments

I'm trying to modify the values of the EnumType config. I do this, by copying the value, execute the callback if needed, modify the array, then write the array back. I don't change the structure, only a value.

But PHPStan keeps saying:

Array (array{values: (callable(): iterable<int, string>|iterable<string, mixed>)|iterable<int|string, mixed>}) does not accept (callable(): iterable<int, string>|iterable<string, mixed>)|iterable<int|string, mixed>.

Please have a look here: https://phpstan.org/r/3c29b577-3ba2-4d17-8bc9-d0284e3c9a36

I believe this is because iterable<string, mixed> is used and therefore PHPStan drops all type safety.

How to solve this? Is this a PHPStan issue?

ruudk avatar Dec 23 '21 19:12 ruudk

Looks like a bug in PHPStan, the reassignment of the copy should definitely work. I think the best way forward is to shrink the example to a minimal reproduction and post a bug report at PHPStan.

spawnia avatar Dec 24 '21 09:12 spawnia

Closing due to lack of feedback.

spawnia avatar Oct 15 '22 11:10 spawnia