Why does not defining array key type end up as mixed type? #7749
Unanswered
balintcodes
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
After a version bump of dependencies in a Symfony project I noticed that since December
symfony/type-infothrows anInvalidArgumentExceptionwhen it faces amixedkey type (see update here).I ended up at
ApiPlatform\Metadata\Util\PropertyInfoToTypeInfoHelper::createTypeFromLegacyValues(). At some point it does the following:Because of this, PHPDoc annotations like so throw an error in entities:
Can anyone help me wrap my head around why this is, and if I understand it right, why a mixed type is returned in every scenario, since
$collectionKeyTypesis always an array?Fixing such annotations in now a big deal, I'm more interesed in the whys:)
Beta Was this translation helpful? Give feedback.
All reactions