8000 bug #58870 [Serializer][Validator] prevent failures around not existi… · symfony/symfony@e26e1f8 · GitHub
[go: up one dir, main page]

Skip to content

Commit e26e1f8

Browse files
bug #58870 [Serializer][Validator] prevent failures around not existing TypeInfo classes (xabbuh)
This PR was merged into the 7.1 branch. Discussion ---------- [Serializer][Validator] prevent failures around not existing TypeInfo classes | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | | License | MIT Having a `getType()` method on an extractor is not enough. Such a method may exist to be forward-compatible with the TypeInfo component. We still must not call it if the TypeInfo component is not installed to prevent running into errors for not-defined classes when the TypeInfo component is not installed. Commits ------- 386453e prevent failures around not existing TypeInfo classes
2 parents 7e0faf3 + 386453e commit e26e1f8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ private function getType(string $currentClass, string $attribute): Type|array|nu
992992
*/
993993
private function getPropertyType(string $className, string $property): Type|array|null
994994
{
995-
if (method_exists($this->propertyTypeExtractor, 'getType')) {
995+
if (class_exists(Type::class) && method_exists($this->propertyTypeExtractor, 'getType')) {
996996
return $this->propertyTypeExtractor->getType($className, $property);
997997
}
998998

src/Symfony/Component/Validator/Mapping/Loader/PropertyInfoLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function loadClassMetadata(ClassMetadata $metadata): bool
195195
*/
196196
private function getPropertyTypes(string $className, string $property): TypeInfoType|array|null
197197
{
198-
if (method_exists($this->typeExtractor, 'getType')) {
198+
if (class_exists(TypeInfoType::class) && method_exists($this->typeExtractor, 'getType')) {
199199
return $this->typeExtractor->getType($className, $property);
200200
}
201201

0 commit comments

Comments
 (0)
0