Skip to content

Commit a54667e

Browse files
committed
non-falsy-string cannot be false
1 parent f615b1a commit a54667e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/Type/Accessory/AccessoryNonFalsyStringType.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ public function toInteger(): Type
187187
return TypeCombinator::remove(new IntegerType(), new ConstantIntegerType(0));
188188
}
189189

190+
public function toBoolean(): BooleanType
191+
{
192+
return new ConstantBooleanType(true);
193+
}
194+
190195
public function toFloat(): Type
191196
{
192197
return new FloatType();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class Foo {
1212
*/
1313
public function bar($nonFalseyString, $truthyString) {
1414
assertType('int<min, -1>|int<1, max>', (int) $nonFalseyString);
15+
assertType('true', (bool) $nonFalseyString);
1516
// truthy-string is an alias for non-falsy-string
1617
assertType('non-falsy-string', $truthyString);
1718
}

0 commit comments

Comments
 (0)