@@ -77,12 +77,19 @@ private function loadValidatorType(array &$property, Type $type, $arrayized = fa
77
77
$ rules = [];
78
78
79
79
if (($ restrictions = $ type ->getRestriction ()) && $ checks = $ restrictions ->getChecks ()) {
80
+ $ propertyType = isset ($ property ['type ' ]) ? $ property ['type ' ] : null ;
80
81
foreach ($ checks as $ key => $ check ) {
81
82
switch ($ key ) {
82
83
case 'enumeration ' :
83
84
$ rules [] = [
84
85
'Choice ' => [
85
- 'choices ' => array_map (function ($ enum ) {
86
+ 'choices ' => array_map (function ($ enum ) use ($ propertyType ) {
87
+ if ($ propertyType === 'int ' ) {
88
+ return (int )$ enum ['value ' ];
89
+ }
90
+ if ($ propertyType === 'float ' ) {
91
+ return (float )$ enum ['value ' ];
92
+ }
86
93
return $ enum ['value ' ];
87
94
}, $ check ),
88
95
],
@@ -250,7 +257,7 @@ private function loadValidatorElement(array &$property, ElementItem $element)
250
257
* from a schema attribute including required rule.
251
258
*
252
259
* @param AttributeItem $element
253
- * @param bool $arrayize
260
+ * @param bool $arrayize
254
261
*/
255
262
private function loadValidatorAttribute (array &$ property , AttributeItem $ attribute )
256
263
{
@@ -273,8 +280,8 @@ private function loadValidatorAttribute(array &$property, AttributeItem $attribu
273
280
* Override necessary to improve method to load validations from schema type.
274
281
*
275
282
* @param PHPClass $class
276
- * @param array $data
277
- * @param string $name
283
+ * @param array $data
284
+ * @param string $name
278
285
*/
279
286
protected function visitSimpleType (&$ class , &$ data , SimpleType $ type , $ name )
280
287
{
@@ -295,7 +302,7 @@ protected function visitSimpleType(&$class, &$data, SimpleType $type, $name)
295
302
* Override necessary to improve method to load validations from schema element.
296
303
*
297
304
* @param PHPClass $class
298
- * @param bool $arrayize
305
+ * @param bool $arrayize
299
306
*
300
307
* @return PHPProperty
301
308
*/
@@ -328,8 +335,8 @@ protected function &visitAttribute(&$class, Schema $schema, AttributeItem $attri
328
335
* Responsible for handler all properties from extension types.
329
336
*
330
337
* @param PHPClass $class
331
- * @param array $data
332
- * @param string $parentName
338
+ * @param array $data
339
+ * @param string $parentName
333
340
*/
334
341
protected function &handleClassExtension (&$ class , &$ data , Type $ type , $ parentName )
335
342
{
0 commit comments