-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PropertyInfo] Support multiple types (union types) for collection values #38093
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
To do so I suggest to create new extractor delegating to PHPStan's PHPDoc parser: https://github.com/phpstan/phpdoc-parser |
I started looking at this issue, #38987 is the first step (being possible to have multiple types), second step will be to add a new extractor with phpstan's parser. |
…eys & values (Korbeil) This PR was merged into the 5.3-dev branch. Discussion ---------- [PropertyInfo] Support multiple types for collection keys & values | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | yes | Deprecations? | yes | Tickets | #38093 | License | MIT | Doc PR | N/A This PR is here to introduce multiple types for collection keys & values. Today, we support types as following: `A|B|C` thanks to `getTypes` interface (in extractors) but we do not support union types in collection keys or values, such as `array<A|B|C>`. This PR will allow this. In a next PR, we'll introduce an Extractor that will parse phpDoc in order to have union types in collection keys or values. I tried to introduce as few depreciations as possible, we have only 2 of them here: - `Type::getCollectionKeyType` - `Type::getCollectionValueType` Commits ------- 84dd178 Support multiple types for collection keys & values
Thank you for this suggestion. |
Yes, just didn't had time to work on this lately ~ |
Description
This is a follow-up for #37559.
The PropertyInfo component cannot identify collection values with a union type value like
array<string|int>
at the moment. Currently, it's only possible to identify singular types (e.g.string
or\A
) or types that are nullable (e.g.string|null
) for the collection value.Example
Following types cannot be identified at the moment:
and so on..
The text was updated successfully, but these errors were encountered: