Skip to content

Commit 2a03c92

Browse files
authored
Fix wrong message - Instanceof between Xxx and string
1 parent 034e0c8 commit 2a03c92

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Rules/Classes/ImpossibleInstanceOfRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ public function processNode(Node $node, Scope $scope): array
7979
$addTip(RuleErrorBuilder::message(sprintf(
8080
'Instanceof between %s and %s will always evaluate to false.',
8181
$expressionType->describe(VerbosityLevel::typeOnly()),
82-
$classType->describe(VerbosityLevel::typeOnly()),
82+
$classType->describe(VerbosityLevel::getRecommendedLevelByType($classType)),
8383
)))->build(),
8484
];
8585
} elseif ($this->checkAlwaysTrueInstanceof) {
8686
return [
8787
$addTip(RuleErrorBuilder::message(sprintf(
8888
'Instanceof between %s and %s will always evaluate to true.',
8989
$expressionType->describe(VerbosityLevel::typeOnly()),
90-
$classType->describe(VerbosityLevel::typeOnly()),
90+
$classType->describe(VerbosityLevel::getRecommendedLevelByType($classType)),
9191
)))->build(),
9292
];
9393
}

tests/PHPStan/Rules/Classes/ImpossibleInstanceOfRuleTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function testInstanceof(): void
6262
94,
6363
],
6464
[
65-
'Instanceof between string and string will always evaluate to false.',
65+
'Instanceof between string and \'str\' will always evaluate to false.',
6666
98,
6767
],
6868
[
@@ -169,12 +169,12 @@ public function testInstanceof(): void
169169
419,
170170
],
171171
[
172-
'Instanceof between class-string<DateTimeInterface> and string will always evaluate to false.',
172+
'Instanceof between class-string<DateTimeInterface> and \'DateTimeInterface\' will always evaluate to false.',
173173
432,
174174
$tipText,
175175
],
176176
[
177-
'Instanceof between DateTimeInterface and string will always evaluate to true.',
177+
'Instanceof between DateTimeInterface and \'DateTimeInterface\' will always evaluate to true.',
178178
433,
179179
$tipText,
180180
],
@@ -200,7 +200,7 @@ public function testInstanceofWithoutAlwaysTrue(): void
200200
94,
201201
],
202202
[
203-
'Instanceof between string and string will always evaluate to false.',
203+
'Instanceof between string and \'str\' will always evaluate to false.',
204204
98,
205205
],
206206
[
@@ -266,7 +266,7 @@ public function testInstanceofWithoutAlwaysTrue(): void
266266
419,
267267
],
268268
[
269-
'Instanceof between class-string<DateTimeInterface> and string will always evaluate to false.',
269+
'Instanceof between class-string<DateTimeInterface> and \'DateTimeInterface\' will always evaluate to false.',
270270
432,
271271
$tipText,
272272
],

0 commit comments

Comments
 (0)