-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[PropertyInfo] fix array types with keys (array<string, string>) #37559
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
|
|
||
| if ('[]' === substr($docType, -2)) { | ||
| if ('mixed[]' === $docType) { | ||
| $collectionKeyType = null; |
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 code was never executed. in case of a mixed[] type on the variable, $docType was array, so I removed this code.
131f362 to
ab80d9e
Compare
|
I just noticed that the build is failing for older PHP versions, please let me check first. Update: Fixed it. It was because older versions of the phpdocumenter reflection package did not allow/parse spaces in |
ab80d9e to
f7f49c9
Compare
77974e2 to
93882ea
Compare
|
We would consider this as a new feature indeed. Can you rebase and target master please? |
93882ea to
d118c6e
Compare
d118c6e to
34a1c69
Compare
|
How is the status of this merge request, I stumbled over this issue by myself right now? |
34a1c69 to
64f7bd7
Compare
|
/cc @dunglas could you maybe have a look? |
|
Thank you @digilist. |
|
Hello, is there a known workaround to wait to next property-info patch release? |
We used |
|
You can use something like this: @var MyOwnClass[]
@phpstan-var array<string, MyOwnClass>That should satisfy phpstan and the serializer. |
|
@Marmelatze Thank you for your suggestion. The phpstan annotation works, but the normal |
|
You could use |
Thank you, this worked perfectly! Looking forward to the 5.2 release though! |
Array types with keys are currently not detected correctly from the PropertyInfo component:
Those are currently identified as object with class
rray<string, string>.This PR tries to fix it.
What I noticed while fixing this, is that union types in arrays are not supported in general at the moment, because the
Typeclass supports only one collectionValueType and I do not see how to pass a Union Type there. But I guess that's a different issue and for those types I decided to return null as collection value type for now. (Or better throw on exception?)