Skip to content

Ability to add tips to other errors via extension #15805

Open
phpstan/phpstan-src
#7246

Description

@canvural

Feature request

Hello,

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?

No response

Activity

  1. staabm commented on Nov 23, 2026

    @staabm
    Contributor

    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

  2. ondrejmirtes commented on Nov 24, 2026

    @ondrejmirtes
    Member

    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...

  3. canvural commented on Nov 27, 2026

    @canvural
    ContributorAuthor

    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.

  4. ondrejmirtes commented on Nov 27, 2026

    @ondrejmirtes
    Member

    This could be something very similar to https://apiref.phpstan.org/2.3.x/PHPStan.Analyser.IgnoreErrorExtension.html, feel free to implement it 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions