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
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update PropertyInfo tests
  • Loading branch information
DerManoMann committed Feb 22, 2025
commit 49a43b40b67fa7e852a2be0972fb3f3a14f5448d
Original file line number Diff line number Diff line change
Expand Up @@ -946,25 +946,24 @@ public function testPseudoTypes(string $property, ?Type $type)
*/
public static function pseudoTypesProvider(): iterable
{
yield ['classString', Type::string()];
yield ['classString', Type::explicitString('class-string')];

// BC layer for type-info < 7.2
if (!interface_exists(WrappingTypeInterface::class)) {
yield ['classStringGeneric', Type::generic(Type::string(), Type::object(\stdClass::class))];
} else {
yield ['classStringGeneric', Type::string()];
yield ['classStringGeneric', Type::explicitString('class-string')];
}

yield ['htmlEscapedString', Type::string()];
yield ['lowercaseString', Type::string()];
yield ['nonEmptyLowercaseString', Type::string()];
yield ['nonEmptyString', Type::string()];
yield ['numericString', Type::string()];
yield ['traitString', Type::string()];
yield ['interfaceString', Type::string()];
yield ['literalString', Type::string()];
yield ['positiveInt', Type::int()];
yield ['negativeInt', Type::int()];
yield ['htmlEscapedString', Type::explicitString('html-escaped-string')];
yield ['lowercaseString', Type::explicitString('lowercase-string')];
yield ['nonEmptyLowercaseString', Type::explicitString('non-empty-lowercase-string')];
yield ['nonEmptyString', Type::explicitString('non-empty-string')];
yield ['numericString', Type::explicitString('numeric-string')];
yield ['traitString', Type::explicitString('trait-string')];
yield ['interfaceString', Type::explicitString('interface-string')];
yield ['positiveInt', Type::intRange(1, \PHP_INT_MAX)];
yield ['negativeInt', Type::intRange(\PHP_INT_MIN, -1)];
yield ['nonEmptyArray', Type::array()];
yield ['nonEmptyList', Type::list()];
yield ['scalar', Type::union(Type::int(), Type::float(), Type::string(), Type::bool())];
Expand Down Expand Up @@ -1001,9 +1000,9 @@ public function testExtractorIntRangeType(string $property, ?Type $type)
*/
public static function intRangeTypeProvider(): iterable
{
yield ['a', Type::int()];
yield ['b', Type::nullable(Type::int())];
yield ['c', Type::int()];
yield ['a', Type::intRange(0, 100)];
yield ['b', Type::nullable(Type::intRange(\PHP_INT_MIN, 100))];
yield ['c', Type::intRange(50, \PHP_INT_MAX)];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/TypeInfo/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CHANGELOG
7.3
---

* Add `IntRangeType` and `ExplicitStringType` classes to capture more specific type detals for `int` and `string` builtin types
* Add `IntRangeType` and `ExplicitStringType` classes to hold specific type details for `int` and `string` builtin types
* Add `Type::accepts()` method
* Add `TypeFactoryTrait::fromValue()` method
* Deprecate constructing a `CollectionType` instance as a list that is not an array
Expand Down
0