Skip to content

Commit 2b6f0fe

Browse files
committed
more precise strings
1 parent 2b89bf1 commit 2b6f0fe

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Type/StringType.php

+3
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ public function toArrayKey(): Type
184184
public function toCoercedArgumentType(bool $strictTypes): Type
185185
{
186186
if (!$strictTypes) {
187+
if ($this->isNumericString()->no()) {
188+
return TypeCombinator::union($this, $this->toBoolean());
189+
}
187190
return TypeCombinator::union($this->toInteger(), $this->toFloat(), $this, $this->toBoolean());
188191
}
189192

tests/PHPStan/Analyser/nsrt/bug-12393b.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function doFoo(string $s): void
160160
public function doBar(): void
161161
{
162162
$this->foo = 'foo';
163-
assertType('0', $this->foo); // should be *NEVER*
163+
assertType('*NEVER*', $this->foo);
164164
}
165165
}
166166

0 commit comments

Comments
 (0)