yamadashy / phpstan-friendly-formatter

🤝 A friendly error formatter extension for PHPStan that provides more readable and informative output, including code snippets and color highlighting.
https://packagist.org/packages/yamadashy/phpstan-friendly-formatter
MIT License
44 stars 1 forks source link

highlight expected and actual value in error messages #13

Open staabm opened 1 week ago

staabm commented 1 week ago

thank you for this nice formatter.

I want to suggest to color or format the expected and actual value of rule errors, since these are usually the most important part of an error message. additionaly these are often-times only separated by a single , so e.g. on big array shapes its pretty hard to see where the actual value ended and where the expected value begins

something like

grafik

yamadashy commented 1 week ago

Thank you for your feedback and suggestion!

I understand you're proposing to make PHPStan's error messages more human-readable and easier to understand. You're right; if we can achieve this as a formatter, it would indeed be very helpful.

Currently, our formatter is outputting PHPStan's error messages as-is. These messages lack consistency in their format, which could make parsing them challenging. However, I think it's worth exploring this idea further.

staabm commented 1 week ago

thanks for getting back to me.

there is currently a discussion on how the data can/needs to be represented to ease use from error formatters: https://github.com/phpstan/phpstan/discussions/11581#discussioncomment-10496619

yamadashy commented 1 week ago

Thank you for following up and sharing that discussion link. I wasn't aware of this ongoing conversation about improving error formatters in PHPStan.

The approach discussed in phpstan/phpstan#11581 indeed looks promising. It would be a significant enhancement if such functionality were integrated directly into PHPStan. This kind of improvement could greatly benefit all error formatters, including ours.

While i want to avoid simply copying their ideas, I'll review the thread carefully and see how i might incorporate similar concepts in a way that's appropriate for friendly formatter.

Thank you again for bringing this to our attention.