Skip to content

Commit 0f82775

Browse files
committed
refactor: enforce string at datetime casting
1 parent a9bfa3c commit 0f82775

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/JsonSchema/Constraints/FormatConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public function check(&$element, $schema = null, ?JsonPointer $path = null, $i =
176176

177177
protected function validateDateTime($datetime, $format)
178178
{
179-
$dt = \DateTime::createFromFormat($format, $datetime);
179+
$dt = \DateTime::createFromFormat($format, (string) $datetime);
180180

181181
if (!$dt) {
182182
return false;

tests/Constraints/FormatTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public function getInvalidFormats(): array
186186
['1999-01-11T00:00:00+1:00', 'date-time'],
187187
['1999.000Z-01-11T00:00:00+1:00', 'date-time'],
188188

189-
[(string) PHP_INT_MAX, 'utc-millisec'],
189+
[PHP_INT_MAX, 'utc-millisec'],
190190

191191
['grey', 'color'],
192192
['#HHH', 'color'],

0 commit comments

Comments
 (0)