-
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
Expand AssertSameWithCountRule to support sizeof #8
Conversation
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.
Hi, thanks for the PR, I found a few issues you should fix.
return [ | ||
'You should use assertCount($expectedCount, $variable) instead of assertSame($expectedCount, count($variable)).', | ||
]; | ||
$method = strtolower($right->name->toString()); |
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's not a method
, it's a functionName
.
|
||
if ($method === 'count') { | ||
return [ | ||
sprintf($message, 'count'), |
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.
What about sprintf($message, $method)
instead of this if/else?
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.
Shouldn’t we verify if the function is count
or sizeof
? I followed the if that was here 😁
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.
OK, just try to simplify the code somehow :)
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.
Okay 👨💻
@@ -36,10 +36,13 @@ public function processNode(Node $node, Scope $scope): array | |||
if ( | |||
$right instanceof Node\Expr\FuncCall | |||
&& $right->name instanceof Node\Name | |||
&& strtolower($right->name->toString()) === 'count' | |||
&& in_array(strtolower($right->name->toString()), ['count', 'sizeof']) |
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.
@ondrejmirtes Should I assigned the functionName
inside the if, or is fine to repeat strtolower($right->name->toString()
?
As suggested in #7, I've expand
AssertSameWithCountRule
to supportcount
's alias:sizeof
👍