Discussed in #7749
Originally posted by balintcodes February 11, 2026
Hi there,
After a version bump of dependencies in a Symfony project I noticed that since December symfony/type-info throws an InvalidArgumentException when it faces a mixed key type (see update here).
I ended up at ApiPlatform\Metadata\Util\PropertyInfoToTypeInfoHelper::createTypeFromLegacyValues(). At some point it does the following:
$variableTypes[] = \is_array($collectionKeyTypes) ? Type::mixed() : Type::union(Type::int(), Type::string()); // @phpstan-ignore-line
Because of this, PHPDoc annotations like so throw an error in entities:
/*
*@return array<string>
*/
private array $foo = [];
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 $collectionKeyTypes is always an array?
Fixing such annotations in now a big deal, I'm more interesed in the whys:)
Discussed in #7749
Originally posted by balintcodes February 11, 2026
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:)