[PropertyInfo] Support multiple builtinType (union types)#38987
[PropertyInfo] Support multiple builtinType (union types)#38987Korbeil wants to merge 1 commit intosymfony:5.xfrom
Conversation
5e52c97 to
16eee13
Compare
0d3648c to
1487518
Compare
786b60e to
bbe2949
Compare
src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php
Outdated
Show resolved
Hide resolved
bbe2949 to
bf96c1a
Compare
ec3a8e5 to
d7655cd
Compare
|
I don't think that's the right representation of a union type. Currently, an object type is represented as So to support union types, I think we would need something dealing with an array of |
d7655cd to
585ef24
Compare
971cfcc to
00d3325
Compare
It's actually true, but I don't think we should have multiple objects to describe that, it should be stored in a single object. It also highlight another issue that I would like to solve: use a separate parameter for the management of nullability when it should be included in builtin types from the beginning. Can't we try to think on new object to manage this ? Something like My ideal implementation would be something like this: https://gist.github.com/Korbeil/3cfaa05878657f4150bdb0ce0fb0b0e6 |
To me, the actual issue is more distinguishing builtin types from class types actually. nullability as separate made sense in PHP 7 where any type would be prefixed by |
Do you already have some ideas about how to do that ? I actually can't think of a new object representation without some needed compatibility layer to avoid BC. |
|
I fear we'll not be able to prevent the compatibility layer. I like @stof proposal of returning an array of |
|
We should probably return some kind of object wrapping an array of types, rather than a raw array of types. Otherwise, we'll face an issue again if/when we need to add support for intersection types (which also deal with a list of types, but not the same than for union types) |
|
If we want to fit that in the existing structure of the Type object, we might use |
00d3325 to
bb4ccaa
Compare
|
I'll close this for now since the issue is not representating union types since |
First step for #38093, before parsing union types in phpDoc, we need to handle union types correctly in the
Typeclass.I changed the
$builtinTypetype in theTypeconstruct in order to handle multiple builtin types.