Skip to content

Commit 621abb8

Browse files
committed
Use sprintf instead of new branch to return correct error message
1 parent 1a7f3e1 commit 621abb8

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

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

+5-9
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,13 @@ public function processNode(Node $node, Scope $scope): array
5555
&& ($leftType->isSuperTypeOf($rightType)->yes())
5656
&& ($rightType->isSuperTypeOf($leftType)->yes())
5757
) {
58-
if (strtolower($node->name->name) === 'assertnotequals') {
59-
return [
60-
RuleErrorBuilder::message(
61-
'You should use assertNotSame() instead of assertNotEquals(), because both values are scalars of the same type',
62-
)->identifier('phpunit.assertEquals')->build(),
63-
];
64-
}
65-
6658
return [
6759
RuleErrorBuilder::message(
68-
'You should use assertSame() instead of assertEquals(), because both values are scalars of the same type',
60+
sprintf(
61+
'You should use %s() instead of %s(), because both values are scalars of the same type',
62+
strtolower($node->name->name) === 'assertnotequals' ? 'assertNotSame' : 'assertSame',
63+
$node->name->name,
64+
),
6965
)->identifier('phpunit.assertEquals')->build(),
7066
];
7167
}

0 commit comments

Comments
 (0)