-
Notifications
You must be signed in to change notification settings - Fork 51
feat: remove SlevomatCodingStandard.Operators.DisallowEqualOperators #289
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
Conversation
We can use phpstan for that which handles it better https://phpstan.org/r/977a0017-a744-4a9c-8bc8-6e580ff5ec1b
Where is the breaking change? |
I guess this was not tested. And I consider breaking that CS will not check it any further. |
What is the exact configuration under which PHPStan flags this? When I uncheck any of the "Strict rules" and We have one such error deliberately suppressed in the PHP_CodeSniffer configuration for the DBAL but I do not believe this error is reported by PHPStan in the current configuration. It would be nice to document the upgrade path to keep these errors reported if the coding standard will no longer do that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO still to be preserved: I don't use phpstan, and psalm is perfectly fine with non-strict comparisons.
this but checked @morozov Where can I document this eventually? @Ocramius reasonable as well. I don't use psalm anymore as there's no support for intersections etc. But sure, not everyone uses phpstan. Dunno how Doctrine want to approach this but CS is kind of stupid in terms of checking things that SA should check instead so I'd rather remove those rules that fall into that category. |
I'd start here. |
+1 that the coding standard should focus primarily on code formatting. Basically, enforcing a certain way of doing things that can be done in multiple ways (e.g. tabs vs. spaces, order of import statements, the position of curly braces, etc). Enforcing strict comparison over loose is not enforcing one of the many equal options. |
Static analysis verifies correctness: |
Totally disagree. |
As I said, from a SA PoV, |
It is fine. But as I said, I believe a coding standard should focus on code formatting, not on semantics. As long as |
Since it seems like there isn't clarity, let me ask this the opposite way: why would psalm deny Preventing usage of What an SA tool does is evaluating the context of each expression, to determine validity . Seems like a scope mismatch to me. |
No idea. I'd guess that if the operands are not strictly typed, it is possible that the code may not work as expected in certain cases. If we put the upgrade path aside, the "why psalm" question is out of the scope of this discussion. I'm trying to make a point that such a rule doesn't belong to a coding standard which this project is about. |
Yup, it is the same as #258 which is stale. Let's not check SA issues using CS. Use CS only for stylistics. Let SA issues be handled individually. There are people who use either phpstan/psalm or both with custom flavours. |
My point is that it is an upfront stylistic choice (much like early returns, preventing nested ternaries, or usage of I didn't read logical arguments against this reasoning here, so far. I will gladly change my mind after that happens though 👍 |
@simPod #258 is the same: you can rely on type inference and skip declaring types, or declare the types and make sure they align with inference. The SA engine can usually work with it anyway. As an extreme example, in Haskell, you can decide to declare function signatures and implementation, or just the implementation. The decision whether the signature should be declared or not falls on the developer: the type analysis doesn't care. Enforcing the declaration of type signatures is a stylistic choice. |
It seems we all have different baseline what stylistic issue is. From my POV, usage of Same is with |
I disallow Pretty much style decision. Style is not just "alignment". |
This, I agree with. The ~same thing, written differently. |
My stylistic decision is to avoid It is, ironically, pretty much the same scenario of |
Also, I know it is a frustratingly long discussion (sorry for that), but this is probably also the best place to hold this sort of discussion. |
I did not realise that to such detail. I'll prefer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems we all have different baseline what stylistic issue is. From my POV, usage of
empty()
is not stylistic issue.
Code style is not purely about code formatting and PHPCS is not just a glorified code-formatter. If we disallow empty()
or ==
, that means that we as the Doctrine project agreed not to write code that uses those operations. And yes, that is a stilistic choice.
My understanding is that you still don't want to allow ==
in codebases you maintain and neither is this rule broken or abandoned in any way. Your motivation is (correct me if I'm wrong) to remove a redundancy since two tools you are using combined with the settings you are using would report the same error. I don't think that this redundancy alone is problematic enough to remove the rule.
Furthermore, codebases that don't use PHPStan or configure PHPStand to run without the strict ruleset would still benefit from this rule if we keep it.
tl;dr: I'd like to keep the rule.
Aight, thx for input everyone! |
We can use phpstan for that which handles it better
https://phpstan.org/r/977a0017-a744-4a9c-8bc8-6e580ff5ec1b (strict+bleeding edge checked)