Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error messages from collectors #8334

Open
staabm opened this issue Nov 9, 2022 · 1 comment
Open

error messages from collectors #8334

staabm opened this issue Nov 9, 2022 · 1 comment

Comments

@staabm
Copy link
Contributor

staabm commented Nov 9, 2022

Feature request

using collectors you often create error messages which are not tight to a specific file

e.g. as described in https://tomasvotruba.com/blog/how-to-measure-your-type-coverage/
you get a output of:

 vendor/bin/phpstan analyze  -c phpstan.neon.dist
 355/355 [============================] 100%

 ------ ---------------------------------------------------------------------------------------------------------
  Line   N/A
 ------ ---------------------------------------------------------------------------------------------------------
  -1     Out of 1295 possible param types, only 57 % actually have it. Add more param types to get over 99 %
  -1     Out of 1582 possible return types, only 32 % actually have it. Add more return types to get over 99 %
  -1     Out of 873 possible property types, only 0 % actually have it. Add more property types to get over 99 %
 ------ ---------------------------------------------------------------------------------------------------------

as you can see, in this case we get a error-line reported as -1 and a file of N/A.

I think for error messages which are not related to a file, the result table should not print out a line - as it doesn't make sense to print a line number, when no filename is known.

therefore I would prefer a result table like

 vendor/bin/phpstan analyze  -c phpstan.neon.dist
 355/355 [============================] 100%

 ---------------------------------------------------------------------------------------------------------
    Out of 1295 possible param types, only 57 % actually have it. Add more param types to get over 99 %
    Out of 1582 possible return types, only 32 % actually have it. Add more return types to get over 99 %
    Out of 873 possible property types, only 0 % actually have it. Add more property types to get over 99 %
 ---------------------------------------------------------------------------------------------------------

for this kind of errors

@ondrejmirtes
Copy link
Member

The documentation https://phpstan.org/developing-extensions/collectors states this:

Because these custom CollectedDataNode rules are executed out of context, the reported errors should specify the file and line to report:

So what https://tomasvotruba.com/blog/how-to-measure-your-type-coverage/ is doing is invalid usage I'd say. But I understand it might be useful...

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

No branches or pull requests

2 participants