psalm: DX: improve error messages
InvalidArgument: Argument 2 of rex_instance_pool_trait::getInstance expects callable(string…):object|null, Closure(mixed):(null|rex_media&static) provided
The separation of the expected value and the actual value is done by a single ,. Its really hard to read. I would suggest something like
InvalidArgument: Argument 2 of rex_instance_pool_trait::getInstance expects callable(string…):object|null but Closure(mixed):(null|rex_media&static) provided
I cant think of something with even more words in between which would be even better
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 3
- Comments: 20 (7 by maintainers)
I built a little tool to parse and display Psalm array error messages in what’s hopefully a helpful way: https://ifixit.github.io/psalm-error-parser/
It’s hosted on GitHub pages and written entirely in JS.
Here’s an example: copy-pasting the first error from https://psalm.dev/r/876f473d2c results in this view:
instead of this:
<tt>
INFO: LessSpecificReturnStatement - 7:12 - The type ‘array{config: array{bread: 42, chalk: ‘some’}, greeting: ‘hello’}’ is more general than the declared return type ‘array{config: array{bread: int, cheese: int}, greeting: string}’ for takesAnInt
</tt>
Upper case words could provide easy visual anchors
Snippets are nice, but messages need to be readable too, for contexts like LSP diagnostics.
In my example I changed
,for the wordbut…But I agree, as mentioned earlier, there will be better alternatives.
I also thought about a
diffformatted style of actual vs expected types