8000 [TypeInfo] Add `IntRangeType` to hold specific type details for `int` builtin types by DerManoMann · Pull Request #59676 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[TypeInfo] Add IntRangeType to hold specific type details for int builtin types #59676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Prev Previous commit
Next Next commit
Make intRange tests conditional
  • Loading branch information
DerManoMann committed Feb 22, 2025
commit 007cb6d7df599c791eb188ef53d0a6fbbbed6797
Original file line number Diff line number Diff line change
Expand Up @@ -971,8 +971,10 @@ public static function pseudoTypesProvider(): iterable
yield ['arrayKey', Type::union(Type::int(), Type::string())];
yield ['double', Type::float()];

yield ['positiveInt', Type::intRange(1)];
yield ['negativeInt', Type::intRange(\PHP_INT_MIN, -1)];
if (method_exists(Type::class, 'intRange')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (method_exists(Type::class, 'intRange')) {
// BC layer for symfony/type-info < 7.3
if (method_exists(Type::class, 'intRange')) {

yield ['positiveInt', Type::intRange(1)];
yield ['negativeInt', Type::intRange(\PHP_INT_MIN, -1)];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It misses the else

}

public function testDummyNamespace()
Expand Down Expand Up @@ -1002,9 +1004,15 @@ public function testExtractorIntRangeType(string $property, ?Type $type)
*/
public static function intRangeTypeProvider(): iterable
{
yield ['a', Type::intRange(0, 100)];
yield ['b', Type::nullable(Type::intRange(\PHP_INT_MIN, 100))];
yield ['c', Type::intRange(50, \PHP_INT_MAX)];
if (method_exists(Type::class, 'intRange')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (method_exists(Type::class, 'intRange')) {
// BC layer for symfony/type-info < 7.3
if (method_exists(Type::class, 'intRange')) {

yield ['a', Type::intRange(0, 100)];
yield ['b', Type::nullable(Type::intRange(\PHP_INT_MIN, 100))];
yield ['c', Type::intRange(50, \PHP_INT_MAX)];
} else {
yield ['a', Type::int()];
yield ['b', Type::nullable(Type::int())];
yield ['c', Type::int()];
}
}

/**
Expand Down
Loading
0