Skip to content

Commit 3427699

Browse files
Revert "non-falsy-string cannot be converted to 0"
This reverts commit f615b1a.
1 parent 8862b0d commit 3427699

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/Type/Accessory/AccessoryNonFalsyStringType.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
use PHPStan\Type\Traits\TruthyBooleanTypeTrait;
3232
use PHPStan\Type\Traits\UndecidedComparisonCompoundTypeTrait;
3333
use PHPStan\Type\Type;
34-
use PHPStan\Type\TypeCombinator;
3534
use PHPStan\Type\UnionType;
3635
use PHPStan\Type\VerbosityLevel;
3736

@@ -184,7 +183,7 @@ public function toAbsoluteNumber(): Type
184183

185184
public function toInteger(): Type
186185
{
187-
return TypeCombinator::remove(new IntegerType(), new ConstantIntegerType(0));
186+
return new IntegerType();
188187
}
189188

190189
public function toFloat(): Type

tests/PHPStan/Analyser/nsrt/bug-10893.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
function hasMicroseconds(\DateTimeInterface $value, string $str): bool
1111
{
1212
assertType('non-falsy-string&numeric-string', $str);
13-
assertType('int<min, -1>|int<1, max>', (int)$str);
14-
assertType('true', (int)$str !== 0);
13+
assertType('int', (int)$str);
14+
assertType('bool', (int)$str !== 0);
1515

1616
assertType('non-falsy-string&numeric-string', $value->format('u'));
17-
assertType('int<min, -1>|int<1, max>', (int)$value->format('u'));
18-
assertType('true', (int)$value->format('u') !== 0);
17+
assertType('int', (int)$value->format('u'));
18+
assertType('bool', (int)$value->format('u') !== 0);
1919

2020
assertType('non-falsy-string&numeric-string', $value->format('v'));
21-
assertType('int<min, -1>|int<1, max>', (int)$value->format('v'));
22-
assertType('true', (int)$value->format('v') !== 0);
21+
assertType('int', (int)$value->format('v'));
22+
assertType('bool', (int)$value->format('v') !== 0);
2323

2424
assertType('float', $value->format('u') * 1e-6);
2525
assertType('float', $value->format('v') * 1e-3);

tests/PHPStan/Analyser/nsrt/non-falsy-string.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Foo {
1111
* @param truthy-string $truthyString
1212
*/
1313
public function bar($nonFalseyString, $truthyString) {
14-
assertType('int<min, -1>|int<1, max>', (int) $nonFalseyString);
14+
assertType('int', (int) $nonFalseyString);
1515
// truthy-string is an alias for non-falsy-string
1616
assertType('non-falsy-string', $truthyString);
1717
}

0 commit comments

Comments
 (0)