-
Notifications
You must be signed in to change notification settings - Fork 46
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
AssertEqualsIsDiscouraged #6
base: 1.1.x
Are you sure you want to change the base?
Conversation
if ( | ||
($leftType instanceof BooleanType && $rightType instanceof BooleanType) | ||
|| ($leftType instanceof IntegerType && $rightType instanceof IntegerType) | ||
|| ($leftType instanceof StringType && $rightType instanceof StringType) |
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.
You might be able to simplify this condition with Type::isSupersetOf()
and a UnionType consisting of bool, int and string. cc @JanTvrdik might help you with 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.
I'm not sure if the union would mean the same thing here. Both (left and right) need to be of the same type (not in the union of bool|int|string
)
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.
Maybe union + \get_class($leftType) === \get_class($rightType)
?
if ( | ||
($leftType instanceof FloatType && $rightType instanceof FloatType) | ||
&& | ||
count($node->args) < 4 // is not using delta for comparing floats |
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.
This newline isn't necessary.
} | ||
|
||
$fileContents = explode("\n", file_get_contents($scope->getFile())); | ||
$previousLine = $fileContents[$node->getLine() - 2]; |
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 don't like this. You should look into $node
properties instead, there should be a comment available.
I submitted a review 😊 Also please rebase your branch on master and fix PHP 7.1-related CS errors. |
f9b30da
to
bb05c60
Compare
R4R @ondrejmirtes (I kept the fixes in the separate commits for easier review) |
bb05c60
to
ac956fe
Compare
ac956fe
to
433dacf
Compare
Any feedback on this one? |
433dacf
to
122e716
Compare
c315145
to
0e9a3a4
Compare
TBH I don't think this belongs here directly, it should be in phpstan-strict-rules (or i.e. phpstan-phpunit-strict-rules), or at least in separate ruleset (i.e. |
0e9a3a4
to
61291dc
Compare
I just made a very similar rule to my package, check it out and feel free to comment. It forbids |
af60919
to
e8572b7
Compare
This rule is even more opinionated than the previous ones.
If you don't think it should be included in PHPStan, I can change it and keep only the first part (which suggests
assertSame
in for the same types)