Closed
Description
Symfony version(s) affected
6.2.8
Description
Since removing the TypeResolver 1.7 restriction in this commit, I'm getting serialisation errors when classes have docblocks that are not collections.
For example, if I use Psalms "value-of" docblock, the Serializer thinks this is an array of Type, but in reality it's just a string.
How to reproduce
final class StatusClass
{
final public const STATUS_VALUES = ['accept', 'reject'];
/**
* @param value-of<self::STATUS_VALUES> $status
*/
public function __construct(
public readonly string $status,
) {
}
}
Attempt to serialise data that looks a little like this and you'll receive an error that $status is an "array".
Possible Solution
-
Replace in user-land code @param with @psalm-param. Psalm still understands the type, but the serializer doesn't.
-
Re-add the composer restriction until this issue in TypeResolver is resolved: Generics are always considered as Collection phpDocumentor/TypeResolver#180
Additional Context
No response