Skip to content

Commit bc0a290

Browse files
kubawerlosondrejmirtes
authored andcommitted
Do not use "strtolower" when there is a dedicated method
1 parent f9bfc19 commit bc0a290

4 files changed

+6
-9
lines changed

Diff for: src/Rules/PHPUnit/AssertSameBooleanExpectedRule.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use PHPStan\Analyser\Scope;
1111
use PHPStan\Rules\Rule;
1212
use function count;
13-
use function strtolower;
1413

1514
/**
1615
* @implements Rule<NodeAbstract>
@@ -35,7 +34,7 @@ public function processNode(Node $node, Scope $scope): array
3534
if (count($node->getArgs()) < 2) {
3635
return [];
3736
}
38-
if (!$node->name instanceof Node\Identifier || strtolower($node->name->name) !== 'assertsame') {
37+
if (!$node->name instanceof Node\Identifier || $node->name->toLowerString() !== 'assertsame') {
3938
return [];
4039
}
4140

Diff for: src/Rules/PHPUnit/AssertSameNullExpectedRule.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use PHPStan\Analyser\Scope;
1111
use PHPStan\Rules\Rule;
1212
use function count;
13-
use function strtolower;
1413

1514
/**
1615
* @implements Rule<NodeAbstract>
@@ -35,7 +34,7 @@ public function processNode(Node $node, Scope $scope): array
3534
if (count($node->getArgs()) < 2) {
3635
return [];
3736
}
38-
if (!$node->name instanceof Node\Identifier || strtolower($node->name->name) !== 'assertsame') {
37+
if (!$node->name instanceof Node\Identifier || $node->name->toLowerString() !== 'assertsame') {
3938
return [];
4039
}
4140

Diff for: src/Rules/PHPUnit/AssertSameWithCountRule.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use PHPStan\Rules\Rule;
1212
use PHPStan\Type\ObjectType;
1313
use function count;
14-
use function strtolower;
1514

1615
/**
1716
* @implements Rule<NodeAbstract>
@@ -36,7 +35,7 @@ public function processNode(Node $node, Scope $scope): array
3635
if (count($node->getArgs()) < 2) {
3736
return [];
3837
}
39-
if (!$node->name instanceof Node\Identifier || strtolower($node->name->name) !== 'assertsame') {
38+
if (!$node->name instanceof Node\Identifier || $node->name->toLowerString() !== 'assertsame') {
4039
return [];
4140
}
4241

@@ -45,7 +44,7 @@ public function processNode(Node $node, Scope $scope): array
4544
if (
4645
$right instanceof Node\Expr\FuncCall
4746
&& $right->name instanceof Node\Name
48-
&& strtolower($right->name->toString()) === 'count'
47+
&& $right->name->toLowerString() === 'count'
4948
) {
5049
return [
5150
'You should use assertCount($expectedCount, $variable) instead of assertSame($expectedCount, count($variable)).',
@@ -55,7 +54,7 @@ public function processNode(Node $node, Scope $scope): array
5554
if (
5655
$right instanceof Node\Expr\MethodCall
5756
&& $right->name instanceof Node\Identifier
58-
&& strtolower($right->name->toString()) === 'count'
57+
&& $right->name->toLowerString() === 'count'
5958
&& count($right->getArgs()) === 0
6059
) {
6160
$type = $scope->getType($right->var);

Diff for: src/Rules/PHPUnit/ShouldCallParentMethodsRule.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private function hasParentClassCall(?array $stmts, string $methodName): bool
9797
continue;
9898
}
9999

100-
if (strtolower($stmt->expr->name->name) === $methodName) {
100+
if ($stmt->expr->name->toLowerString() === $methodName) {
101101
return true;
102102
}
103103
}

0 commit comments

Comments
 (0)