Description
Symfony version(s) affected
5.3 - 6.3
Description
PhpDocExtractor is not able to return nullable array value types and throws exception with invalid class name/invalid type. Example phpDoc:
/**
* @var array<?\DateTime>
*/
public array $arrayOfNullableDateTimes;
/**
* @var array<\DateTime|null>
*/
public array $arrayOfNullableDateTimes2;
PhpDocExtractor is also unable to return mutliple value/key data types in array/collection. Example phpDoc:
/**
* @var array<int|string>
*/
public $arrayOfMultipleValueTypes;
How to reproduce
To reproduce use PropertyInfo component with PhpDocExtractor. Error will be shown, when extracting type from property with nullable array value type. Also when extracting type from property with multiple array key/value type, empty arrry will be returned.
Possible Solution
To fix the problem, use getType instead of createType in PhpDocTypeHelper. To add multiple array value/key types return all extracted types (remove count check). I will also make a PR with solution.
Additional Context
No response