Skip to content

Commit 3088f94

Browse files
Fix
1 parent 12271ac commit 3088f94

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

src/Rules/Comparison/ImpossibleCheckTypeFunctionCallRule.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PHPStan\Parser\LastConditionVisitor;
88
use PHPStan\Rules\Rule;
99
use PHPStan\Rules\RuleErrorBuilder;
10+
use function count;
1011
use function sprintf;
1112
use function strtolower;
1213

src/Rules/Comparison/ImpossibleCheckTypeMethodCallRule.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use PHPStan\Rules\Rule;
1111
use PHPStan\Rules\RuleErrorBuilder;
1212
use PHPStan\ShouldNotHappenException;
13+
use function count;
1314
use function sprintf;
1415

1516
/**
@@ -45,7 +46,7 @@ public function processNode(Node $node, Scope $scope): array
4546
}
4647

4748
$addTip = function (RuleErrorBuilder $ruleErrorBuilder) use ($scope, $node, $reasons): RuleErrorBuilder {
48-
if (count($reasons)) {
49+
if (count($reasons) > 0) {
4950
return $ruleErrorBuilder->acceptsReasonsTip($reasons);
5051
}
5152

src/Rules/Comparison/ImpossibleCheckTypeStaticMethodCallRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use PHPStan\Rules\Rule;
1111
use PHPStan\Rules\RuleErrorBuilder;
1212
use PHPStan\ShouldNotHappenException;
13+
use function count;
1314
use function sprintf;
1415

1516
/**
@@ -46,7 +47,6 @@ public function processNode(Node $node, Scope $scope): array
4647

4748
$addTip = function (RuleErrorBuilder $ruleErrorBuilder) use ($scope, $node, $reasons): RuleErrorBuilder {
4849
if (count($reasons) > 0) {
49-
var_dump($reasons);die;
5050
return $ruleErrorBuilder->acceptsReasonsTip($reasons);
5151
}
5252

src/Type/Accessory/AccessoryLowercaseStringType.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use PHPStan\Type\Type;
3131
use PHPStan\Type\UnionType;
3232
use PHPStan\Type\VerbosityLevel;
33+
use function sprintf;
3334

3435
class AccessoryLowercaseStringType implements CompoundType, AccessoryType
3536
{
@@ -110,9 +111,14 @@ public function isSubTypeOfWithReason(Type $otherType): IsSuperTypeOfResult
110111
return $otherType->isSuperTypeOfWithReason($this);
111112
}
112113

113-
return (new IsSuperTypeOfResult($otherType->isLowercaseString(), [
114-
sprintf("%s is not lowercase.", $otherType->describe(VerbosityLevel::value())),
115-
]))
114+
$isLowercase = $otherType->isLowercaseString();
115+
116+
return (new IsSuperTypeOfResult(
117+
$isLowercase,
118+
$otherType->isString()->yes() && $isLowercase->no()
119+
? [sprintf("%s is not lowercase.", $otherType->describe(VerbosityLevel::value()))]
120+
: []
121+
))
116122
->and($otherType instanceof self ? IsSuperTypeOfResult::createYes() : IsSuperTypeOfResult::createMaybe());
117123
}
118124

tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ public function testBug11799(): void
11121112
11,
11131113
"• 'publishDate' is not lowercase.
11141114
• 'approvedAt' is not lowercase.
1115-
• 'allowedValues' is not lowercase."
1115+
• 'allowedValues' is not lowercase.",
11161116
],
11171117
]);
11181118
}

0 commit comments

Comments
 (0)