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

Add excludes neon formatter #2523

Closed

Conversation

marcelthole
Copy link
Contributor

Hi,

i have created a NeonExcludes Error Formatter to create a exludes.neon file. This file could be used as a baseline for a higher PHPStan level.
We can upgrade to phpstan level max and create the excludes.neon file. This file should be included and the new code could be validated with the higher level.

$formatter = new NeonExcludesErrorFormatter();

$this->assertSame($exitCode, $formatter->formatErrors(
$this->getAnalysisResult($numFileErrors, $numGenericErrors),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe i should add different error messages with special characters like #, <, \, \n, 😃, ', ", \n

@ondrejmirtes
Copy link
Member

Thank you very much for this! I took this idea and improved on it a bit:

I introduced count property for ignoreErrors records for a single path: 71a5f12

And then improved your error formatter to actually generate the file with count keys: e779a80

This is how a generated files looks like now: 2518159

I will release this feature as 0.11.17, I hope I'll find to write an article about this tomorrow.

@marcelthole
Copy link
Contributor Author

That's awesome. This looks much better than my version.
I don't know why, but i received some neon format errors with the single line messages. So i have to switched to the multiline version. But with my test code base i didn't get the error with your updated version.

@marcelthole marcelthole deleted the add-excludes-neon-formatter branch October 19, 2019 20:20
@ondrejmirtes
Copy link
Member

Yes, it happened to me to and it was because Symfony output butchered some escaping around < and >. This is how I fixed it: 03f20e6 (Symfony Console uses HTML-like tags for formatting.)

@ondrejmirtes
Copy link
Member

I released it and described in this article :) https://medium.com/@ondrejmirtes/phpstans-baseline-feature-lets-you-hold-new-code-to-a-higher-standard-e77d815a5dff

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

Successfully merging this pull request may close these issues.

None yet

2 participants