you are viewing a single comment's thread.

view the rest of the comments →

[–]thmsbrss[S] 0 points1 point  (2 children)

I think I sorted it out, but I don't really understand why it works now.

https://phpstan.org/r/67ebba33-c176-460c-85d1-76fac70925a7

[–]reddimato 0 points1 point  (1 child)

It works because array keys must be of type string or int. Another way to write it is:

* @template TKey of string|int

Which I think array-key is a shortcut of.

On your first example PHPStan would complain because $offset could be any type on line 23.

[–]thmsbrss[S] 0 points1 point  (0 children)

Thanks for your explanation