Skip to content

Commit 5dbc5de

Browse files
committed
more precise strings
1 parent 3bf7dd1 commit 5dbc5de

8 files changed

+9
-9
lines changed

src/Type/Accessory/AccessoryLiteralStringType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public function toArrayKey(): Type
217217
public function toCoercedArgumentType(bool $strictTypes): Type
218218
{
219219
if (!$strictTypes) {
220-
return TypeCombinator::union(new IntegerType(), new FloatType(), new StringType(), new BooleanType());
220+
return TypeCombinator::union($this->toInteger(), $this->toFloat(), $this, $this->toBoolean());
221221
}
222222

223223
return $this;

src/Type/Accessory/AccessoryLowercaseStringType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public function toArrayKey(): Type
214214
public function toCoercedArgumentType(bool $strictTypes): Type
215215
{
216216
if (!$strictTypes) {
217-
return TypeCombinator::union(new IntegerType(), new FloatType(), new StringType(), new BooleanType());
217+
return TypeCombinator::union($this->toInteger(), $this->toFloat(), $this, $this->toBoolean());
218218
}
219219

220220
return $this;

src/Type/Accessory/AccessoryNonEmptyStringType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public function toArrayKey(): Type
214214
public function toCoercedArgumentType(bool $strictTypes): Type
215215
{
216216
if (!$strictTypes) {
217-
return TypeCombinator::union(new IntegerType(), new FloatType(), new StringType(), new BooleanType());
217+
return TypeCombinator::union($this->toInteger(), $this->toFloat(), $this, $this->toBoolean());
218218
}
219219

220220
return $this;

src/Type/Accessory/AccessoryNonFalsyStringType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public function toArrayKey(): Type
216216
public function toCoercedArgumentType(bool $strictTypes): Type
217217
{
218218
if (!$strictTypes) {
219-
return TypeCombinator::union(new IntegerType(), new FloatType(), new StringType(), new BooleanType());
219+
return TypeCombinator::union($this->toInteger(), $this->toFloat(), $this, $this->toBoolean());
220220
}
221221

222222
return $this;

src/Type/Accessory/AccessoryNumericStringType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public function toArrayKey(): Type
216216
public function toCoercedArgumentType(bool $strictTypes): Type
217217
{
218218
if (!$strictTypes) {
219-
return TypeCombinator::union(new IntegerType(), new FloatType(), new StringType(), new BooleanType());
219+
return TypeCombinator::union($this->toInteger(), $this->toFloat(), $this, $this->toBoolean());
220220
}
221221

222222
return $this;

src/Type/Accessory/AccessoryUppercaseStringType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public function toArrayKey(): Type
214214
public function toCoercedArgumentType(bool $strictTypes): Type
215215
{
216216
if (!$strictTypes) {
217-
return TypeCombinator::union(new IntegerType(), new FloatType(), new StringType(), new BooleanType());
217+
return TypeCombinator::union($this->toInteger(), $this->toFloat(), $this, $this->toBoolean());
218218
}
219219

220220
return $this;

src/Type/StringType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function toArrayKey(): Type
184184
public function toCoercedArgumentType(bool $strictTypes): Type
185185
{
186186
if (!$strictTypes) {
187-
return TypeCombinator::union(new IntegerType(), new FloatType(), new StringType(), new BooleanType());
187+
return TypeCombinator::union($this->toInteger(), $this->toFloat(), $this, $this->toBoolean());
188188
}
189189

190190
return $this;

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

Lines changed: 2 additions & 2 deletions
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('int', $this->foo);
163+
assertType('0', $this->foo);
164164
}
165165
}
166166

@@ -292,7 +292,7 @@ public function doFoo(string $b): void
292292
public function doBar(): void
293293
{
294294
$this->foo = "1.0";
295-
assertType('float|int', $this->foo);
295+
assertType('1|1.0', $this->foo);
296296
}
297297
}
298298

0 commit comments

Comments
 (0)