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)

Most upvoted comments

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: image 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

InvalidArgument: Argument 2 of rex_instance_pool_trait::getInstance EXPECTS callable(string…):object|null GOT Closure(mixed):(null|rex_media&static) instead

Snippets are nice, but messages need to be readable too, for contexts like LSP diagnostics.

I do do agree the messaging could be a bit more concise, however I don’t think : vs. , makes much of a difference. I’ve been contemplating another output format that’s more visual based, but don’t know exactly what it would look like yet.

In my example I changed , for the word but

But I agree, as mentioned earlier, there will be better alternatives.

I also thought about a diff formatted style of actual vs expected types