Open M1ke opened 3 years ago
I found these snippets:
If we unset the first key instead then Psalm has no issues with modifying it
https://psalm.dev/r/d6609968af
However if we modify an internal item (even if we explicitly check it exists first) the same issue is thrown.
I found these snippets:
class-string-map https://psalm.dev/docs/annotating_code/type_syntax/utility_types/#class-string-mapt-of-foo-t does exactly this for class instances. We would need a more generic type to be used for cases of "normal" arrays (and lists) To get this to work correctly too https://psalm.dev/r/c39fbb3124
I found these snippets:
https://psalm.dev/r/c75c90c4ec
The issue here is that we're wanting the docblock to declare that the function must return the input param. Psalm instead requires us to permit the function to return either the input value, or an alternative array that shares a similar type description.
This means that the common goal of "a function that takes an array, modifies it and returns it" can't be represented without also permitting the function to take an array, discard it and return something that looks like it.