Skip to content

Commit

Permalink
types::intRange() should return literal if min === max
Browse files Browse the repository at this point in the history
  • Loading branch information
vudaltsov committed Feb 24, 2024
1 parent 676a388 commit 771a658
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/types.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ public static function intRange(?int $min = null, ?int $max = null): Type
return self::int;
}

if ($min === $max) {
return self::literalValue($min);

Check failure on line 236 in src/types.php

View workflow job for this annotation

GitHub Actions / phpstan (8.1)

Method Typhoon\Type\types::intRange() should return Typhoon\Type\Type<int> but returns Typhoon\Type\Type<bool|float|int|string>.

Check failure on line 236 in src/types.php

View workflow job for this annotation

GitHub Actions / phpstan (8.1)

Parameter #1 $value of static method Typhoon\Type\types::literalValue() expects bool|float|int|string, int|null given.

Check failure on line 236 in src/types.php

View workflow job for this annotation

GitHub Actions / phpstan (8.1)

Unable to resolve the template type TValue in call to method static method Typhoon\Type\types::literalValue()

Check failure on line 236 in src/types.php

View workflow job for this annotation

GitHub Actions / phpstan (8.2)

Method Typhoon\Type\types::intRange() should return Typhoon\Type\Type<int> but returns Typhoon\Type\Type<bool|float|int|string>.

Check failure on line 236 in src/types.php

View workflow job for this annotation

GitHub Actions / phpstan (8.2)

Parameter #1 $value of static method Typhoon\Type\types::literalValue() expects bool|float|int|string, int|null given.

Check failure on line 236 in src/types.php

View workflow job for this annotation

GitHub Actions / phpstan (8.2)

Unable to resolve the template type TValue in call to method static method Typhoon\Type\types::literalValue()

Check failure on line 236 in src/types.php

View workflow job for this annotation

GitHub Actions / psalm (8.1)

PossiblyNullArgument

src/types.php:236:39: PossiblyNullArgument: Argument 1 of Typhoon\Type\types::literalValue cannot be null, possibly null value provided (see https://psalm.dev/078)

Check failure on line 236 in src/types.php

View workflow job for this annotation

GitHub Actions / psalm (8.2)

PossiblyNullArgument

src/types.php:236:39: PossiblyNullArgument: Argument 1 of Typhoon\Type\types::literalValue cannot be null, possibly null value provided (see https://psalm.dev/078)

Check failure on line 236 in src/types.php

View workflow job for this annotation

GitHub Actions / phpstan (8.3)

Method Typhoon\Type\types::intRange() should return Typhoon\Type\Type<int> but returns Typhoon\Type\Type<bool|float|int|string>.

Check failure on line 236 in src/types.php

View workflow job for this annotation

GitHub Actions / phpstan (8.3)

Parameter #1 $value of static method Typhoon\Type\types::literalValue() expects bool|float|int|string, int|null given.

Check failure on line 236 in src/types.php

View workflow job for this annotation

GitHub Actions / phpstan (8.3)

Unable to resolve the template type TValue in call to method static method Typhoon\Type\types::literalValue()

Check failure on line 236 in src/types.php

View workflow job for this annotation

GitHub Actions / psalm (8.3)

PossiblyNullArgument

src/types.php:236:39: PossiblyNullArgument: Argument 1 of Typhoon\Type\types::literalValue cannot be null, possibly null value provided (see https://psalm.dev/078)
}

return new IntRangeType($min, $max);
}

Expand Down

0 comments on commit 771a658

Please sign in to comment.