You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ability to add tips to other errors via extension #15805
I did not think this through 100% yet, just dumping an idea I just had.
Sometimes the errors PHPStan report can be ambiguous or the cause of the error might not be too obvious to the developer. Or the cause can be highly specific to the codebase. And the codebase "knows" why this error happens and provide better help messages. Of course this could be done with custom rules, but that'd duplicate some work.
So I had a thought what if PHPStan allowed developers to add tips to any error messages. It could work similarly to ignore error extensions I guess.
Like I said just an idea. Didn't think about if it's even possible or any edge cases. But would love to brainstorm.
Did PHPStan help you today? Did it make you happy in any way?
more interessting would be a few concrete use-cases so we can validate whether it would actually work and how many/which context such a extension would need to make good decisions
Wouldn't a custom error formatter be sufficient here? Wrap an existing one with composition (constructor injection), change the AnalysisResult, call the existing formatter with your tips...
Error formatter would not cut it. Cause I only have access to the error text there. I need the node and scope to decide if a tip can be added.
For example for some property not found errors, it is due to some misconfiguration or lack of configuration in Laravel models. And it is not obvious just to say the property is undefined. A tip would guide the developer to the right place.
Activity
staabm commentedon Nov 23, 2026
implementation wise I guess it would be easy.
more interessting would be a few concrete use-cases so we can validate whether it would actually work and how many/which context such a extension would need to make good decisions
ondrejmirtes commentedon Nov 24, 2026
Wouldn't a custom error formatter be sufficient here? Wrap an existing one with composition (constructor injection), change the AnalysisResult, call the existing formatter with your tips...
canvural commentedon Nov 27, 2026
Error formatter would not cut it. Cause I only have access to the error text there. I need the node and scope to decide if a tip can be added.
For example for some property not found errors, it is due to some misconfiguration or lack of configuration in Laravel models. And it is not obvious just to say the property is undefined. A tip would guide the developer to the right place.
ondrejmirtes commentedon Nov 27, 2026
This could be something very similar to https://apiref.phpstan.org/2.3.x/PHPStan.Analyser.IgnoreErrorExtension.html, feel free to implement it 😊