Conversation
rules.neon Outdated
- | ||
class: PHPStan\Rules\PHPUnit\AssertEqualsIsDiscouragedRule | ||
arguments: | ||
strictRulesInstalled: %strictRulesInstalled% |
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.
I'd rather use conditionalTags instead of passing the parameter in the rule.
Also: we can do it only on bleeding edge. Conditional tags can do and
condition based on multiple parameters since phpstan/phpstan-src#1697 (see the tests).
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.
TIL, thanks
public function getNodeType(): string | ||
{ | ||
return NodeAbstract::class; |
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.
I feel like they have a more specific class parent than just NodeAbstract. Feel free to check out and optimize other similar rules as well.
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.
fixed here and will do for more rules in a separate PR with a 1.4.x target in #217
10880da
into phpstan:2.0.x Uh oh!
There was an error while loading. Please reload this page.
Hi @staabm, just saw this new rules. I feel like it should be stricter. It's like if we were reporting Enforcing a stricter comparison, like |
the goal of this PRs rule is about reporting assertions which can use strict-comparison without risk (unnecessary loose comparision).
I think what you are suggesting is about "always true/false" errors (so verification of arguments given to AssertEquals) which sounds like a separate rule (maybe its even already implemented.. did not check) |
I understood that, but then it doesn't require to be behind the There is already rules asking to change things like
All these changes are safe. And not behind the I would think that
The same way |
this turns a strict comparison into a different syntax but still strict comparison
if this is how regular strict-rules comparison work, then it makes sense to me (did not check). |
Simplified version which is concentrated on the main point: point people to
assertSame
when possible.I intentionally stripped of the "assertEquals is fine when a comment is given" case, as I think its not important.
closes #6
refs #7