Ver Fonte

added 'double' type

Johannes Schmitt há 14 anos atrás
pai
commit
346cae9cba

+ 2 - 0
Resources/doc/index.rst

@@ -208,6 +208,8 @@ Available Types:
 +---------------------------+--------------------------------------------------+
 | integer                   | Primitive integer                                |
 +---------------------------+--------------------------------------------------+
+| double                    | Primitive double                                 |
++---------------------------+--------------------------------------------------+
 | string                    | Primitive string                                 |
 +---------------------------+--------------------------------------------------+
 | array                     | An array with arbitrary keys, and values.        |

+ 3 - 0
Serializer/Normalizer/NativePhpTypeNormalizer.php

@@ -71,6 +71,8 @@ class NativePhpTypeNormalizer extends SerializerAwareNormalizer
             return (integer) $data;
         } else if ('string' === $type) {
             return (string) $data;
+        } else if ('double' === $type) {
+            return (double) $data;
         } else if ('DateTime' === $type) {
             if (!is_array($data) || !isset($data['time'], $data['timezone'])) {
                 throw new RuntimeException('Invalid input data for type "DateTime".');
@@ -136,6 +138,7 @@ class NativePhpTypeNormalizer extends SerializerAwareNormalizer
         return 'boolean' === $type
                || 'integer' === $type
                || 'string' === $type
+               || 'double' === $type
                || 'DateTime' === $type
                || 0 === strpos($type, 'array');
     }