★ wanayoo — archive 1999 https://github.com/phpstan/phpstan-phpunit/pull/8Nouvelle recherche | Portail wanayoo
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

Conversation

@carusogabriel
Copy link
Contributor

@carusogabriel carusogabriel commented Dec 30, 2017

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

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

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

This comment has been minimized.

@ondrejmirtes

ondrejmirtes Jan 1, 2018
Member

It's not a method, it's a functionName.


if ($method === 'count') {
return [
sprintf($message, 'count'),

This comment has been minimized.

@ondrejmirtes

ondrejmirtes Jan 1, 2018
Member

What about sprintf($message, $method) instead of this if/else?

This comment has been minimized.

@carusogabriel

carusogabriel Jan 1, 2018
Author Contributor

Shouldn’t we verify if the function is count or sizeof? I followed the if that was here 😁

This comment has been minimized.

@ondrejmirtes

ondrejmirtes Jan 1, 2018
Member

OK, just try to simplify the code somehow :)

This comment has been minimized.

@carusogabriel

carusogabriel Jan 1, 2018
Author Contributor

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'])

This comment has been minimized.

@carusogabriel

carusogabriel Jan 1, 2018
Author Contributor

@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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.