Skip to content

Commit

Permalink
Condense exception message for wrong array value type
Browse files Browse the repository at this point in the history
  • Loading branch information
cweiske committed Jul 20, 2024
1 parent 599d1c2 commit 30589df
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/JsonMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,8 @@ public function mapArray($json, $array, $class = null, $parent_key = '')
} else if ($this->bStrictObjectTypeChecking) {
throw new JsonMapper_Exception(
'JSON property'
. ' "' . ($parent_key ? $parent_key : '?') . '"'
. ' (array key "' . $key . '") must be an object, '
. gettype($jvalue) . ' given'
. ' "' . ($parent_key ? $parent_key : '?') . '[' . $key . ']"'
. ' must be an object, ' . gettype($jvalue) . ' given'
);
} else {
$array[$key] = $this->createInstance(
Expand Down
2 changes: 1 addition & 1 deletion tests/ObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function testStrictTypeCheckingObjectInArrayError()
{
$this->expectException(JsonMapper_Exception::class);
$this->expectExceptionMessage(
'JSON property "?" (array key "0") must be an object, string given'
'JSON property "?[0]" must be an object, string given'
);
$jm = new JsonMapper();
$jm->bStrictObjectTypeChecking = true;
Expand Down

0 comments on commit 30589df

Please sign in to comment.