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

phpstan: lvl 1 -> 2 #1854

Merged
merged 1 commit into from
Jan 14, 2025
Merged

phpstan: lvl 1 -> 2 #1854

merged 1 commit into from
Jan 14, 2025

Conversation

ostrolucky
Copy link
Member

No description provided.

src/ConnectionFactory.php Outdated Show resolved Hide resolved
path: src/DataCollector/DoctrineDataCollector.php
# Probably needs Symfony plugin
- message: '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\Node#'
path: src/DependencyInjection/Configuration.php
Copy link
Member

Choose a reason for hiding this comment

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

How do you make the choice to user ignoreErrors vs phpstan-ignore? Now that phpstan-ignore comes with error identifier, I think it's good.

Copy link
Member Author

Choose a reason for hiding this comment

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

This rule suppresses 10 violations. It's hard to make a hard rule out of it, but 10 violations of same kind I would say are sufficient. Once we solve underlying issue (like here, maybe it will be solved by symfony plugin), we can remove it from one place instead of hunting it all over. If it was like 3 violations, I would be more inclined to do it inline. But anything in between is subjective.

Copy link
Member

Choose a reason for hiding this comment

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

Now that phpstan-ignore comes with error identifier

We can use those identifiers in the ignore rules of our neon file as well and we should probably do that.

Copy link
Member

Choose a reason for hiding this comment

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

To elaborate, in the past I thought the baseline approach was superior, because using @phpstan-ignore-next-line could hide more than the intended errors. Now that it's possible to do that directly in the code, I think it might be nicer to have the ignore rules close to the code, because sometimes I'm wondering why PHPStan "isn't working". Also, if you see an existing ignore rule in the code, you are more likely to challenge it, if you know how to properly fix it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes normally I prefer inline suppressions (and ask people to do it). There are bunch of issues that prevent us to do it efficiently unfortunately, for example it's not enough for phpstan to suppress missing class when instantiating it, phpstan is not smart enough to understand that if you ignore missing class it's also ok to ignore method calls on such class. So now you have to sprinkle code with suppressions each time such class is used as well. I would expect I can just suppress instantiating class that can be missing, instead of having to suppress dozens of other issues cascading from that as well.

@ostrolucky ostrolucky merged commit 92d19dc into 2.13.x Jan 14, 2025
15 checks passed
@derrabus derrabus deleted the phpstan-lvl2 branch January 14, 2025 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants