1515use Symfony \Component \PropertyInfo \PropertyAccessExtractorInterface ;
1616use Symfony \Component \PropertyInfo \PropertyListExtractorInterface ;
1717use Symfony \Component \PropertyInfo \PropertyTypeExtractorInterface ;
18+ use Symfony \Component \PropertyInfo \Type as LegacyType ;
1819use Symfony \Component \TypeInfo \Type ;
1920use Symfony \Component \Validator \Constraints \All ;
2021use Symfony \Component \Validator \Constraints \Iban ;
@@ -61,6 +62,7 @@ public function testLoadClassMetadata()
6162 private int $ i = 0 ;
6263 private int $ j = 0 ;
6364 private array $ types ;
65+ private array $ legacyTypes ;
6466
6567 public function getType (string $ class , string $ property , array $ context = []): ?Type
6668 {
@@ -84,6 +86,29 @@ public function getType(string $class, string $property, array $context = []): ?
8486
8587 return $ type ;
8688 }
89+
90+ public function getTypes (string $ class , string $ property , array $ context = []): ?array
91+ {
92+ $ this ->legacyTypes ??= [
93+ [new LegacyType ('string ' , true )],
94+ [new LegacyType ('string ' )],
95+ [new LegacyType ('string ' , true ), new LegacyType ('int ' ), new LegacyType ('bool ' )],
96+ [new LegacyType ('object ' , true , Entity::class)],
97+ [new LegacyType ('array ' , true , null , true , null , new LegacyType ('object ' , false , Entity::class))],
98+ [new LegacyType ('array ' , true , null , true )],
99+ [new LegacyType ('float ' , true )], // The existing constraint is float
100+ [new LegacyType ('string ' , true )],
101+ [new LegacyType ('string ' , true )],
102+ [new LegacyType ('array ' , true , null , true , null , new LegacyType ('float ' ))],
103+ [new LegacyType ('string ' )],
104+ [new LegacyType ('string ' )],
105+ ];
106+
107+ $ legacyType = $ this ->legacyTypes [$ this ->j ];
108+ ++$ this ->j ;
109+
110+ return $ legacyType ;
111+ }
87112 };
88113
89114 $ propertyAccessExtractor = $ this ->createMock (PropertyAccessExtractorInterface::class);
@@ -215,6 +240,11 @@ public function getType(string $class, string $property, array $context = []): ?
215240 {
216241 return Type::string ();
217242 }
243+
244+ public function getTypes (string $ class , string $ property , array $ context = []): ?array
245+ {
246+ return [new LegacyType ('string ' )];
247+ }
218248 };
219249
220250 $ propertyAccessExtractor = $ this ->createMock (PropertyAccessExtractorInterface::class);
@@ -249,6 +279,11 @@ public function getType(string $class, string $property, array $context = []): ?
249279 {
250280 return Type::string ();
251281 }
282+
283+ public function getTypes (string $ class , string $ property , array $ context = []): ?array
284+ {
285+ return [new LegacyType ('string ' )];
286+ }
252287 };
253288 }
254289
0 commit comments