Open someniatko opened 10 months ago
Hey @someniatko, can you reproduce the issue on https://psalm.dev ?
Can you please create examples on psalm.dev with code that should pass/fail, because then those psalm.dev examples can be used as unit tests when implementing this feature
@kkmuffme sure!
standalone function: https://psalm.dev/r/dd628f335c instance method: https://psalm.dev/r/92fef9c820 static method: https://psalm.dev/r/98e4a57a38 constructor: https://psalm.dev/r/3697fa812a
idk if this should also work for anon functions, because @no-named-arguments
doesn't: https://psalm.dev/r/030309bc72
I found these snippets:
Psalm has
@no-named-arguments
annotation which forces calling functions or methods by specifying parameters in their order, and allow the function maintainers to change parameter names for refactoring purposes.However, in some cases, like constructors of DTOs with lots of fields, it might be preferable to always use parameter names instead, and in such cases parameter order does not matter. However, for housekeeping purposes sometimes it might be preferable to change this order. If we knew that no user of this DTO coupled to the parameter order, we could freely change it.
Therefore I suggest implementing something like
@only-named-arguments
which forces specifying param names, and emphasizes that their order might change.