-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Allow using generic annotations and not parsing them as an array #41996
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
Comments
Can you create a small example application that allows to reproduce your issue? |
Sure, here it is: https://github.com/awd-studio/symfony-serializer-bug-41996 |
Hey, thanks for your report! |
As I know, it steal can be represented. |
Hey, thanks for your report! |
. |
Hey, thanks for your report! |
ds |
Hey, thanks for your report! |
Could I get an answer? If I do not hear anything I will assume this issue is resolved or abandoned. Please get back to me <3 |
answer |
I think it is because This will be fixed by the introduction of the |
Hey, thanks for your report! |
Could I get an answer? If I do not hear anything I will assume this issue is resolved or abandoned. Please get back to me <3 |
…rface generics (mtarld) This PR was merged into the 5.4 branch. Discussion ---------- [Serializer] [PropertyAccessor] Ignore non-collection interface generics | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #41996 #49924 | License | MIT `PhpDocExtractor` and `PhpStanDocExtractor` are following an old version of PSR-5 with used to define collections as the following: ``` generic = collection-type "<" [type-expression "," *SP] type-expression ">" ``` But, it does conflict with non-collection generics. This issue will automatically be solved if the `TypeInfo` is merged in Symfony. But for older versions (<7.1 at least), it needs a fix. ~I was not able to find a proper bug fix without introducing a BC break, so this PR proposes to opt-on the "non-collection generics" parsing, such as `stcClass<int>` for example.~ ~To opt-out from parsing these generics, it'll be required to set `ignore_docblock_generics` in the context. And this key/value will become obsolete as soon as the `TypeInfo` is introduced.~ ~I'm not sure how to proceed though, should we only merge it in 5.4, and 6.3 supposing that the `TypeInfo` might be merged in 7.x? Should we document it only in these branches?~ EDIT: I finally ignored PHPDoc generics that aren't well known collection generic types so that the process will fall back to other resolvers (such as reflection resolver for example) Commits ------- e31aeeb [PropertyAccessor] Fix unexpected collection when generics
Symfony version(s) affected: 5.3.3
Description
Denormalizer breaks with an error
Data expected to be an array, string given.
when it handles an object, which contains a generic-like annotation, but is not an array or iterable.How to reproduce
Possible Solution
I digged it in PhpDocTypeHelper, which is part of phpDocumentor, so I don't know how to solve it. 😟
The text was updated successfully, but these errors were encountered: