Skip to content

Commit 904151b

Browse files
authored
Merge pull request #95 from Krunch/fix/proper-cast-tolerateStrings
Return properly cast data when using tolerateStrings
2 parents f6557c2 + e3de35d commit 904151b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/Schema.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,10 +1116,6 @@ public function process($data, Context $options, $path = '#', $result = null)
11161116
$data = $options->dataPreProcessor->process($data, $this, $import);
11171117
}
11181118

1119-
if ($result === null) {
1120-
$result = $data;
1121-
}
1122-
11231119
if ($options->skipValidation) {
11241120
goto skipValidation;
11251121
}
@@ -1154,6 +1150,10 @@ public function process($data, Context $options, $path = '#', $result = null)
11541150

11551151
skipValidation:
11561152

1153+
if ($result === null) {
1154+
$result = $data;
1155+
}
1156+
11571157
if ($this->oneOf !== null) {
11581158
$result = $this->processOneOf($data, $options, $path);
11591159
}

tests/src/PHPUnit/TolerateStringsTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,20 @@ public function testWithTolerateStrings()
3535
'2'
3636
];
3737

38+
$expected_data = [
39+
'text',
40+
10,
41+
123.45,
42+
true,
43+
2
44+
];
45+
3846
$options = new Context();
3947
$options->tolerateStrings = true;
4048

4149
$schema = Schema::import($json_schema);
4250

43-
$this->assertSame($data, $schema->in($data, $options));
51+
$this->assertSame($expected_data, $schema->in($data, $options));
4452
}
4553

4654
public function testWithTolerateStringsBadNumber()

0 commit comments

Comments
 (0)