-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer][Validator] Fix not null return from "getCollectionValueTypes" #41463
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
Conversation
c428704
to
c4dcfd1
Compare
@@ -473,13 +473,13 @@ private function validateAndDenormalize(string $currentClass, string $attribute, | |||
if (null !== $collectionKeyType = $type->getCollectionKeyTypes()) { | |||
[$context['key_type']] = $collectionKeyType; | |||
} | |||
} elseif ($type->isCollection() && null !== ($collectionValueType = $type->getCollectionValueTypes()) && \count($collectionValueType) > 0 && Type::BUILTIN_TYPE_ARRAY === $collectionValueType[0]->getBuiltinType()) { | |||
} elseif ($type->isCollection() && \count($collectionValueType = $type->getCollectionValueTypes()) > 0 && Type::BUILTIN_TYPE_ARRAY === $collectionValueType[0]->getBuiltinType()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the argument of count() can never be null? (same below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method has been introduced in symfony/property-info: 5.3
and the method is typehinted to return an array.
public function getCollectionValueTypes(): array |
Thank you @jderusse. |
…etCollectionValueTypes" (jderusse) This PR was merged into the 5.3 branch. Discussion ---------- [Serializer][Validator] Fix not null return from "getCollectionValueTypes" | Q | A | ------------- | --- | Branch? | 5.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Currently experimenting `An exception has been thrown during the rendering of a template ("Notice: Undefined offset: 0").` When a property is an array and PropertyInfo is not able to guess the type of CollectionValue Commits ------- c4dcfd1 Fix not null return from "getCollectionValueTypes"
Currently experimenting
An exception has been thrown during the rendering of a template ("Notice: Undefined offset: 0").
When a property is an array and PropertyInfo is not able to guess the type of CollectionValue