Skip to content

Commit 508090c

Browse files
POC
1 parent ed49747 commit 508090c

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

src/Type/Accessory/AccessoryLowercaseStringType.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ public function isSubTypeOfWithReason(Type $otherType): IsSuperTypeOfResult
110110
return $otherType->isSuperTypeOfWithReason($this);
111111
}
112112

113-
return (new IsSuperTypeOfResult($otherType->isLowercaseString(), []))
113+
return (new IsSuperTypeOfResult($otherType->isLowercaseString(), [
114+
sprintf("%s is not lowercase.", $otherType->describe(VerbosityLevel::value())),
115+
]))
114116
->and($otherType instanceof self ? IsSuperTypeOfResult::createYes() : IsSuperTypeOfResult::createMaybe());
115117
}
116118

tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,4 +1109,19 @@ public function testBug3979(): void
11091109
$this->analyse([__DIR__ . '/data/bug-3979.php'], []);
11101110
}
11111111

1112+
public function testBug11799(): void
1113+
{
1114+
$this->checkAlwaysTrueCheckTypeFunctionCall = true;
1115+
$this->treatPhpDocTypesAsCertain = true;
1116+
$this->analyse([__DIR__ . '/data/bug-11799.php'], [
1117+
[
1118+
"Call to function in_array() with arguments string, array{'publishDate', 'approvedAt', 'allowedValues'} and true will always evaluate to false.",
1119+
11,
1120+
"• 'publishDate' is not lowercase.
1121+
• 'approvedAt' is not lowercase.
1122+
• 'allowedValues' is not lowercase."
1123+
],
1124+
]);
1125+
}
1126+
11121127
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug11799;
4+
5+
function getSomeInput(): string { return random_bytes(100); }
6+
7+
function getSortBy(): string
8+
{
9+
$sortBy = mb_strtolower(getSomeInput());
10+
11+
if (! in_array($sortBy, ['publishDate', 'approvedAt', 'allowedValues'], true)) {
12+
// Do something
13+
}
14+
15+
return $sortBy;
16+
}

0 commit comments

Comments
 (0)