Skip to content

Commit 76bd347

Browse files
committed
non-empty-string can still contain falsy strings as individual characters
1 parent 7c7bbbe commit 76bd347

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/Type/Accessory/AccessoryNonFalsyStringType.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ public function getOffsetValueType(Type $offsetType): Type
112112
return new ErrorType();
113113
}
114114

115-
if ((new ConstantIntegerType(0))->isSuperTypeOf($offsetType)->yes()) {
116-
return new IntersectionType([new StringType(), new AccessoryNonFalsyStringType()]);
117-
}
118-
119115
return new StringType();
120116
}
121117

tests/PHPStan/Rules/Comparison/StrictComparisonOfDifferentTypesRuleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,4 +601,10 @@ public function testBug2851b(): void
601601
$this->analyse([__DIR__ . '/data/bug-2851b.php'], []);
602602
}
603603

604+
public function testBug8158(): void
605+
{
606+
$this->checkAlwaysTrueStrictComparison = true;
607+
$this->analyse([__DIR__ . '/data/bug-8158.php'], []);
608+
}
609+
604610
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Bug8158;
4+
5+
function phone_number_starts_with_zero(string $phone_number): bool
6+
{
7+
return $phone_number && $phone_number[0] === '0';
8+
}

0 commit comments

Comments
 (0)