This commit is contained in:
William Cheng 2023-03-14 11:36:24 +08:00
commit 8b1e80d360
3 changed files with 3 additions and 3 deletions

View File

@ -30,7 +30,7 @@
$asserts[] = new Assert\Date(); $asserts[] = new Assert\Date();
{{/isDate}} {{/isDate}}
{{#isDateTime}} {{#isDateTime}}
$asserts[] = new Assert\DateTime(); $asserts[] = new Assert\Type("DateTime");
{{/isDateTime}} {{/isDateTime}}
{{^isDate}} {{^isDate}}
{{^isDateTime}} {{^isDateTime}}

View File

@ -95,7 +95,7 @@ class JmsSerializer implements SerializerInterface
break; break;
case 'DateTime': case 'DateTime':
case '\DateTime': case '\DateTime':
return new DateTime($data); return is_null($data) ? null :new DateTime($data);
default: default:
throw new RuntimeException(sprintf("Type %s is unsupported", $type)); throw new RuntimeException(sprintf("Type %s is unsupported", $type));
} }

View File

@ -95,7 +95,7 @@ class JmsSerializer implements SerializerInterface
break; break;
case 'DateTime': case 'DateTime':
case '\DateTime': case '\DateTime':
return new DateTime($data); return is_null($data) ? null :new DateTime($data);
default: default:
throw new RuntimeException(sprintf("Type %s is unsupported", $type)); throw new RuntimeException(sprintf("Type %s is unsupported", $type));
} }