-
-
Notifications
You must be signed in to change notification settings - Fork 940
feat(metadata/doctrine): Use Type of TypeInfo instead of PropertyInfo
#6979
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
feat(metadata/doctrine): Use Type of TypeInfo instead of PropertyInfo
#6979
Conversation
9f1eab4 to
99cfee3
Compare
Type of TypeInfo instead of PropertyInfoType of TypeInfo instead of PropertyInfo
99cfee3 to
ffd86b8
Compare
Type of TypeInfo instead of PropertyInfoType of TypeInfo instead of PropertyInfo
d8618a7 to
6e47055
Compare
|
For information, the code can become simpler if the following PRs get merged: symfony/symfony#59844 will update $typeIsResourceClass = function (Type $type) use (&$typeIsResourceClass): bool {
return match (true) {
$type instanceof CollectionType => $type->getCollectionValueType()->isSatisfiedBy($typeIsResourceClass),
$type instanceof WrappingTypeInterface => $type->wrappedTypeIsSatisfiedBy($typeIsResourceClass),
$type instanceof CompositeTypeInterface => $type->composedTypesAreSatisfiedBy($typeIsResourceClass),
default => $type instanceof ObjectType && $this->isResourceClass($type->getClassName()),
};
};to $typeIsResourceClass = fn (Type $type): bool => $type instanceof ObjectType && $this->isResourceClass($type->getClassName());symfony/symfony#59845 will update foreach ($type instanceof CompositeTypeInterface ? $type->getTypes() : [$type] as $t) {
while ($t instanceof WrappingTypeInterface) {
$t = $t->getWrappedType();
}
$typeStrings[] = (string) $t;
}to foreach ($type->traverse() as $t) {
if ($t instanceof CompositeTypeInterface || $t instanceof WrappingTypeInterface) {
continue;
}
$typeStrings[] = (string) $t;
} |
f44914f to
6e47055
Compare
|
Edit: I was wrong about it, there is no need to wait, the deprecation could be merged in Symfony 7.3 |
src/Metadata/Tests/Extractor/PropertyMetadataCompatibilityTest.php
Outdated
Show resolved
Hide resolved
src/Metadata/Property/Factory/ExtractorPropertyMetadataFactory.php
Outdated
Show resolved
Hide resolved
src/Metadata/Property/Factory/SerializerPropertyMetadataFactory.php
Outdated
Show resolved
Hide resolved
aba898d to
cc85008
Compare
4b6eaa7 to
b4ae0b4
Compare
This PR was merged into the 7.3 branch. Discussion ---------- [PropertyInfo] Deprecate `Type` | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | no | Deprecations? | yes | Issues | | License | MIT A new attempt to #53160, now that `symfony/type-info` is not experimental anymore. Deprecates: - `Type` class in favor of the `Type` class of `symfony/type-info` - `PropertyTypeExtractorInterface::getTypes()` in favor of the `PropertyTypeExtractorInterface::getType()` method - `ConstructorArgumentTypeExtractorInterface::getTypesFromConstructor()` in favor of the `ConstructorArgumentTypeExtractorInterface::getTypeFromConstructor()` method The work for upgrading dependent packages has begun already: - api-platform/core#6979 - symfony/ux#2607 Commits ------- 4d2ccf4 Fix md formatting f819aed [PropertyInfo] Deprecate Type
This PR was merged into the 7.3 branch. Discussion ---------- [PropertyInfo] Deprecate `Type` | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | no | Deprecations? | yes | Issues | | License | MIT A new attempt to symfony/symfony#53160, now that `symfony/type-info` is not experimental anymore. Deprecates: - `Type` class in favor of the `Type` class of `symfony/type-info` - `PropertyTypeExtractorInterface::getTypes()` in favor of the `PropertyTypeExtractorInterface::getType()` method - `ConstructorArgumentTypeExtractorInterface::getTypesFromConstructor()` in favor of the `ConstructorArgumentTypeExtractorInterface::getTypeFromConstructor()` method The work for upgrading dependent packages has begun already: - api-platform/core#6979 - symfony/ux#2607 Commits ------- 4d2ccf4ac94 Fix md formatting f819aed8d13 [PropertyInfo] Deprecate Type
b4ae0b4 to
3a78472
Compare
751eae2 to
55956f7
Compare
55956f7 to
bbbae81
Compare
|
I'm merging this starting work, we'll continue working towards the Tests are red for deprecations as we introduced a bunch, no worries the BC layer should be easy enough. I'll cherry-pick everything by keeping the backward layer, thanks @mtarld for starting this! |
…m#6979) Co-authored-by: soyuka <soyuka@users.noreply.github.com> scopes: metadata, doctrine, json-schema
In order to anticipate the deprecation of
PropertyInfo'sTypein favor ofTypeInfo's one, this PR adds a new propertyphpType(the name can be challenged) that will aim to replacebuiltinTypes.What has been done:
ApiProperty::$phpTypeproperty,ApiProperty::getPhpType(), andApiProperty::withPhpType().PropertyInfoToTypeInfoHelper::convertTypeToLegacyTypesto store legacy types inApiProperty::$builtinTypeswhen settingApiProperty::$phpType, this allows API Platform to work "the legacy way" while upgrading other packages.ApiPropertyto allow other API Platform packages to upgrade first.AbstractItemNormalizerto not be dependent on the type order (type order might not be the same with these changes)PropertyTypeExtractorInterface::getType()inDoctrineExtractor(asgetTypesis deprecated)api-platform/metadatato^4.1,symfony/property-infoto^7.1in all packagessymfony/type-info:^7.2inapi-platform/metadataandapi-platform/doctrine