Open rieschl opened 1 year ago
When having an array parameter or return type, psalm does not check if there is a type of the values specified in the docblock. It would be nice to enforce specifying a type (or multiple types) of the array values.
array
For example:
/** * @param array $data * @return array */ function arrayShapes(array $data): array { if (count($data) > 1) { return ['bar']; } return [2]; }
(code snippet in the playground) This should emit errors that no array type is specified, just like PHPStan does (playground) with its "No value type specified in iterable type" rule.
Do you think this is something that could be added to psalm? Thank you for your help!
I found these snippets:
As a workaround you can use https://github.com/slevomat/coding-standard/blob/master/doc/type-hints.md#slevomatcodingstandardtypehintsparametertypehint- and https://github.com/slevomat/coding-standard/blob/master/doc/type-hints.md#slevomatcodingstandardtypehintsreturntypehint-
When having an
array
parameter or return type, psalm does not check if there is a type of the values specified in the docblock. It would be nice to enforce specifying a type (or multiple types) of the array values.For example:
(code snippet in the playground) This should emit errors that no array type is specified, just like PHPStan does (playground) with its "No value type specified in iterable type" rule.
Do you think this is something that could be added to psalm? Thank you for your help!