Description
Symfony version(s) affected: 4.4.10 (but probably also symfony 5)
Description
The ValidatorTypeGuesser (from the form component) can use the Type constraint to guess the field type if no better contraints are available. To guess a DateType component, it compares the type to the string '\DateTime' (with a leading backslash).
In doctrine/annotation 1.10, when the class is specified with as ::class, the leading backslash is now removed, so the DateType is not guessed anymore.
see doctrine/annotations#142
How to reproduce
Create a simple data class with a field annotated only with the Type constraint:
class Data {
/**
* @Assert\Type(\DateTime::class)
*/
public $myDate;
}
Then try to guess the type of the field myDate with doctrine/annotation 1.10 or 1.8.
If testing in a full symfony framework, clear the cache after changing doctrine/annotation, to have the class parsed again.
Possible Solution
Add a test for the string 'DateTime' (without the leading backslash)