Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Type/Accessory/AccessoryNonFalsyStringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ public function toInteger(): Type
return TypeCombinator::remove(new IntegerType(), new ConstantIntegerType(0));
}

public function toBoolean(): BooleanType
{
return new ConstantBooleanType(true);
}

public function toFloat(): Type
{
return new FloatType();
Expand Down
1 change: 1 addition & 0 deletions tests/PHPStan/Analyser/nsrt/non-falsy-string.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Foo {
*/
public function bar($nonFalseyString, $truthyString) {
assertType('int<min, -1>|int<1, max>', (int) $nonFalseyString);
assertType('true', (bool) $nonFalseyString);
// truthy-string is an alias for non-falsy-string
assertType('non-falsy-string', $truthyString);
}
Expand Down
Loading