Skip to content

Commit

Permalink
bug #58870 [Serializer][Validator] prevent failures around not existi…
Browse files Browse the repository at this point in the history
…ng 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
-------

386453ee77b prevent failures around not existing TypeInfo classes
  • Loading branch information
nicolas-grekas committed Nov 14, 2024
2 parents 7afcfbb + c210d2b commit 39ec8be
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Normalizer/AbstractObjectNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ private function getType(string $currentClass, string $attribute): Type|array|nu
*/
private function getPropertyType(string $className, string $property): Type|array|null
{
if (method_exists($this->propertyTypeExtractor, 'getType')) {
if (class_exists(Type::class) && method_exists($this->propertyTypeExtractor, 'getType')) {
return $this->propertyTypeExtractor->getType($className, $property);
}

Expand Down

0 comments on commit 39ec8be

Please sign in to comment.