Skip to content

Commit 61b5dd3

Browse files
authored
Support netresearch/jsonmapper ^5.0 (#101)
1 parent b6d6ce6 commit 61b5dd3

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"php": "^8.1",
88
"ext-curl": "*",
99
"ext-json": "*",
10-
"netresearch/jsonmapper": "^3.0|^4.0",
10+
"netresearch/jsonmapper": "^3.0|^4.0|^5.0",
1111
"monolog/monolog": "^2.0|^3.0",
1212
"vlucas/phpdotenv": "^5.0|^6.0",
1313
"damienharper/adf-tools": "^1.0"

src/JiraClient.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ public function __construct(?ConfigurationInterface $configuration = null, ?Logg
7373

7474
$this->json_mapper = new \JsonMapper();
7575

76+
// Adjust settings for JsonMapper v5.0 BC
77+
if (property_exists($this->json_mapper, 'bStrictNullTypesInArrays')) {
78+
$this->json_mapper->bStrictNullTypesInArrays = false; // if you want to allow nulls in arrays
79+
}
80+
$this->json_mapper->bStrictNullTypes = false; // if you want to allow nulls
81+
$this->json_mapper->bStrictObjectTypeChecking = false; // if you want to disable strict type checking
82+
7683
// Fix "\JiraCloud\JsonMapperHelper::class" syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$'
7784
$this->json_mapper->undefinedPropertyHandler = [new \JiraCloud\JsonMapperHelper(), 'setUndefinedProperty'];
7885

src/ServiceDesk/Request/Request.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ private function map(object $data, object $target)
118118
{
119119
$mapper = new JsonMapper();
120120

121+
// Adjust settings for JsonMapper v5.0 BC
122+
if (property_exists($mapper, 'bStrictNullTypesInArrays')) {
123+
$mapper->bStrictNullTypesInArrays = false; // if you want to allow nulls in arrays
124+
}
125+
$mapper->bStrictNullTypes = false; // if you want to allow nulls
126+
$mapper->bStrictObjectTypeChecking = false; // if you want to disable strict type checking
127+
121128
return $mapper->map(
122129
$data,
123130
$target

0 commit comments

Comments
 (0)