diff --git a/php/src/vaas/Vaas.php b/php/src/vaas/Vaas.php index 3c4dd7de..07ff5c99 100644 --- a/php/src/vaas/Vaas.php +++ b/php/src/vaas/Vaas.php @@ -50,6 +50,7 @@ class Vaas private LoggerInterface $_logger; private VaasOptions $_options; private HttpClient $_httpClient; + private JsonMapper $_jsonMapper; /** */ @@ -61,6 +62,8 @@ public function __construct(?string $vaasUrl, ?LoggerInterface $logger = new Nul $this->_logger->debug("Url: " . $vaasUrl); if ($vaasUrl) $this->_vaasUrl = $vaasUrl; + $this->_jsonMapper = new JsonMapper(); + $this->_jsonMapper->bStrictObjectTypeChecking = false; } /** @@ -248,14 +251,14 @@ private function _waitForAuthResponse(): AuthResponse $result = $result->getContent(); $this->_logger->debug("Result", json_decode($result, true)); $genericObject = \json_decode($result); - $resultObject = (new JsonMapper())->map( + $resultObject = $this->_jsonMapper->map( $genericObject, - new BaseMessage() + BaseMessage::class ); if ($resultObject->kind == Kind::AuthResponse) { - $authResponse = (new JsonMapper())->map( + $authResponse = $this->_jsonMapper->map( $genericObject, - new AuthResponse() + AuthResponse::class ); $this->_logger->debug($result); if ($authResponse->success === false) { @@ -265,9 +268,9 @@ private function _waitForAuthResponse(): AuthResponse } if ($resultObject->kind == Kind::Error) { try { - $errorResponse = (new JsonMapper())->map( + $errorResponse = $this->_jsonMapper->map( $genericObject, - new Error() + Error::class ); } catch (JsonMapper_Exception $e) { // Received error type is not deserializable to Error @@ -320,13 +323,13 @@ private function _waitForVerdict(string $guid): VerdictResponse $result = $result->getContent(); $this->_logger->debug("Result", json_decode($result, true)); $resultObject = json_decode($result); - $baseMessage = (new JsonMapper())->map( + $baseMessage = $this->_jsonMapper->map( $resultObject, new BaseMessage() ); if ($baseMessage->kind == Kind::Error) { try { - $errorResponse = (new JsonMapper())->map( + $errorResponse = $this->_jsonMapper->map( $resultObject, new Error() ); @@ -340,7 +343,7 @@ private function _waitForVerdict(string $guid): VerdictResponse continue; } - $verdictResponse = (new JsonMapper())->map( + $verdictResponse = $this->_jsonMapper->map( $resultObject, new VerdictResponse() ); diff --git a/php/src/vaas/composer.json b/php/src/vaas/composer.json index 145ed36c..bbc19cbe 100644 --- a/php/src/vaas/composer.json +++ b/php/src/vaas/composer.json @@ -16,7 +16,7 @@ "php": "^8.1", "ramsey/uuid": "^4.7 || ^4.2", "textalk/websocket": "^1.6 || ^1.5", - "netresearch/jsonmapper": "^4.4", + "netresearch/jsonmapper": "^5.0", "psr/log": "^1.1 || ^2.0 || ^3.0", "amphp/http-client": "5.1.0", "amphp/file": "3.1.1"