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

Expand AssertSameWithCountRule to support sizeof #8

Closed
wants to merge 2 commits into from
Closed

Expand AssertSameWithCountRule to support sizeof #8

wants to merge 2 commits into from

Conversation

carusogabriel
Copy link
Contributor

As suggested in #7, I've expand AssertSameWithCountRule to support count's alias: sizeof 👍

Copy link
Member

@ondrejmirtes ondrejmirtes left a 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());
Copy link
Member

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'),
Copy link
Member

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?

Copy link
Contributor Author

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 😁

Copy link
Member

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 :)

Copy link
Contributor Author

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'])
Copy link
Contributor Author

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()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants