79254244

Date: 2024-12-05 10:27:46
Score: 2
Natty:
Report link

This is possible if you'll use PhpDocExtractor() insted or in addition to ReflectionExtractor().

So to provide information about array key to Serializer all you need is annotate your array property with type description like this:

/** @var array<string, yourValueType> $arrayProperty */
note: that annotation must begin with /** (not /*)

So what PhpDocExtractor does, it parses the source code of your class. Which may not be that efficient as gathering information from reflection. But it definitely will work as you expecting.

PS: My question to the next generations of people is: How to do this without PhpDocExtractor() ?

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (1):
Posted by: Andrey