Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 7.4 support #45

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
87d3b5a
Downgrade from php8 to php7.4 using rector
germanow Jul 21, 2021
348f700
Removed "Pure" php annotations
germanow Jul 21, 2021
2335685
Removed "ArrayShape" php annotations
germanow Jul 21, 2021
d662d0b
Update composer.lock
germanow Jul 22, 2021
81e4811
Removed throw expression
germanow Jul 22, 2021
b4a68c9
Removed pure
germanow Jul 22, 2021
47704c2
Added testGivenValidResponseWhenParsingTheResultThenTheSignatureVerif…
germanow Jul 23, 2021
d4d78ed
Fix testGivenValidResponseWhenParsingTheResultThenTheSignatureVerifi…
germanow Jul 23, 2021
d24020a
Removed usage of named parameters from tests
germanow Jul 26, 2021
ddd8ed2
Set default array to OutboxResponse messages in order to fix error ac…
germanow Jul 28, 2021
44ff36d
Merge branch 'main' into dev-downgrade-php8
germanow Jul 30, 2021
87c861e
Added support of sending Metadata
germanow Aug 16, 2021
c5cae95
Added support of sending Metadata
germanow Aug 16, 2021
a174b9d
Merge branch 'sending-metadata' into dev-downgrade-php8
germanow Aug 16, 2021
5e97901
Fixed construction of AuthorizationResult
germanow Aug 16, 2021
bdbf21c
Removed wrong constructor from AuthorizationResult. Added constructor…
germanow Aug 16, 2021
df770cf
Fixed accessing before initialization in MessageHeaderParameters
germanow Aug 16, 2021
6a759ac
Fixed UtcDataService::now
germanow Aug 16, 2021
babeb98
Implemented sending chunk info
germanow Aug 16, 2021
3af0932
Fixed typing error in OutboxResponse
germanow Aug 18, 2021
ec5ef40
Added nullable type hint for ListEndpointsParameters in order to prev…
germanow Sep 3, 2021
263f26b
Fixed setting recipients in EncodeMessageService
germanow Sep 6, 2021
9ffb69e
Fixed setting recipients in EncodeMessageService for publish mode
germanow Sep 6, 2021
e893f17
Fixed MessageHeaderParameters.getRecipients for null
germanow Sep 6, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
},
"require": {
"php": "8.*",
"php": ">=7.4",
"ext-dom": "*",
"ext-bcmath": "*",
"ext-mbstring": "*",
Expand Down
409 changes: 260 additions & 149 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Api/Dto/JsonDeserializableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ interface JsonDeserializableInterface
* @return self New onboard response created from data array
* @throws JsonException Could be thrown if th entity can not be deserialized.
*/
public function jsonDeserialize(array|string $jsonData): self;
public function jsonDeserialize($jsonData);
}
}
3 changes: 1 addition & 2 deletions src/Api/Exceptions/AuthorizationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Api\Exceptions {

use Exception;
use JetBrains\PhpStorm\Pure;

/**
* Will be thrown if there is an error during the signature creation process.
Expand All @@ -17,7 +16,7 @@ class AuthorizationException extends BusinessException
* @param int $code The code.
* @param Exception|null $previous Previous exception.
*/
#[Pure] public function __construct(string $message, int $code, Exception $previous = null)
public function __construct(string $message, int $code, Exception $previous = null)
{
parent::__construct($message, $code, $previous);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Exceptions/BusinessException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Api\Exceptions {

use Exception;
use JetBrains\PhpStorm\Pure;

/**
* Wrapper for all internal exceptions.
Expand All @@ -17,7 +16,7 @@ class BusinessException extends Exception
* @param int $code Internal code.
* @param Exception|null $previous Previous exception.
*/
#[Pure] public function __construct(string $message, int $code, Exception $previous = null)
public function __construct(string $message, int $code, Exception $previous = null)
{
parent::__construct($message,
$code, $previous);
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Exceptions/DecodeMessageException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Api\Exceptions {

use Exception;
use JetBrains\PhpStorm\Pure;

/**
* Will be thrown if there is an error while decoding a message from the AR.
Expand All @@ -17,7 +16,7 @@ class DecodeMessageException extends BusinessException
* @param int $code The code.
* @param Exception|null $previous Previous exception.
*/
#[Pure] public function __construct(string $message, int $code, Exception $previous = null)
public function __construct(string $message, int $code, Exception $previous = null)
{
parent::__construct($message, $code, $previous);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Exceptions/MessagingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Api\Exceptions {

use JetBrains\PhpStorm\Pure;

/**
* Generic messaging exception.
Expand All @@ -16,7 +15,7 @@ class MessagingException extends BusinessException
* @param string $message The message.
* @param int $code The code.
*/
#[Pure] public function __construct(string $message, int $code)
public function __construct(string $message, int $code)
{
parent::__construct($message, $code);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Exceptions/OnboardException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Api\Exceptions {

use JetBrains\PhpStorm\Pure;

/**
* Will be thrown if there is an error during the onboard process.
Expand All @@ -16,7 +15,7 @@ class OnboardException extends BusinessException
* @param string $message The message.
* @param int $code The code.
*/
#[Pure] public function __construct(string $message, int $code)
public function __construct(string $message, int $code)
{
parent::__construct($message, $code);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Exceptions/OutboxException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Api\Exceptions {

use JetBrains\PhpStorm\Pure;

/**
* Will be thrown if there is any problem during the interaction with the outbox.
Expand All @@ -16,7 +15,7 @@ class OutboxException extends BusinessException
* @param string $message The message.
* @param int $code The code.
*/
#[Pure] public function __construct(string $message, int $code)
public function __construct(string $message, int $code)
{
parent::__construct($message, $code);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Exceptions/RevokeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Api\Exceptions {

use JetBrains\PhpStorm\Pure;

/**
* Will be thrown if there is an error during the revoke endpoint process.
Expand All @@ -16,7 +15,7 @@ class RevokeException extends BusinessException
* @param string $message The message.
* @param int $code The code.
*/
#[Pure] public function __construct(string $message, int $code)
public function __construct(string $message, int $code)
{
parent::__construct($message, $code);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Exceptions/SignatureException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Api\Exceptions {

use Exception;
use JetBrains\PhpStorm\Pure;

/**
* Will be thrown if there is an error during the signature creation process.
Expand All @@ -17,7 +16,7 @@ class SignatureException extends BusinessException
* @param int $code The code.
* @param Exception|null $previous
*/
#[Pure] public function __construct(string $message, int $code, Exception $previous = null)
public function __construct(string $message, int $code, Exception $previous = null)
{
parent::__construct($message, $code, $previous);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Exceptions/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Api\Exceptions {

use JetBrains\PhpStorm\Pure;

/**
* Will be thrown if the parameters are not valid.
Expand All @@ -15,7 +14,7 @@ class ValidationException extends BusinessException
* Constructor.
* @param string $invalidParameter Invalid parameter
*/
#[Pure] public function __construct(string $invalidParameter)
public function __construct(string $invalidParameter)
{
parent::__construct("Parameters passed are not valid. The following parameter is invalid >>> $invalidParameter", ErrorCodes::PARAMETER_INVALID);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Exceptions/VerificationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Api\Exceptions {

use JetBrains\PhpStorm\Pure;

/**
* Will be thrown if there is an error during the verification process.
Expand All @@ -16,7 +15,7 @@ class VerificationException extends BusinessException
* @param string $message The message.
* @param int $code The code.
*/
#[Pure] public function __construct(string $message, int $code)
public function __construct(string $message, int $code)
{
parent::__construct($message, $code);
}
Expand Down
17 changes: 12 additions & 5 deletions src/Dto/Messaging/Http/Inner/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,25 @@ class Command implements JsonDeserializableInterface

private ?string $message = null;

public function jsonDeserialize(array|string $jsonData): JsonDeserializableInterface
/**
* @param mixed[]|string $jsonData
*/
public function jsonDeserialize($jsonData): JsonDeserializableInterface
{
if (is_string($jsonData)) {
$decodedJsonDataArray = json_decode($jsonData, true);
} else {
$decodedJsonDataArray = $jsonData;
}
foreach ($decodedJsonDataArray as $fieldName => $fieldValue) {
$this->message = match ($fieldName) {
self::MESSAGE => $fieldValue,
default => throw new JsonException("Unknown field '$fieldName' for class '" . get_class($this) . "'.", ErrorCodes::UNKNOWN_FIELD_IN_JSON_DATA),
};
switch ($fieldName) {
case self::MESSAGE:
$this->message = $fieldValue;
break;
default:
throw new JsonException("Unknown field '$fieldName' for class '" . get_class($this) . "'.", ErrorCodes::UNKNOWN_FIELD_IN_JSON_DATA);
break;
}
}
return $this;
}
Expand Down
5 changes: 4 additions & 1 deletion src/Dto/Messaging/Http/Inner/OutboxMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ class OutboxMessage implements JsonDeserializableInterface
private ?string $sensorAlternateId = null;
private ?Command $command = null;

public function jsonDeserialize(array|string $jsonData): JsonDeserializableInterface
/**
* @param mixed[]|string $jsonData
*/
public function jsonDeserialize($jsonData): JsonDeserializableInterface
{
if (is_string($jsonData)) {
$decodedJsonDataArray = json_decode($jsonData, true);
Expand Down
9 changes: 6 additions & 3 deletions src/Dto/Messaging/Http/OutboxResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ class OutboxResponse implements JsonDeserializableInterface
*/
private ?array $messages = null;

public function jsonDeserialize(array|string $jsonData): JsonDeserializableInterface
/**
* @param mixed[]|string $jsonData
*/
public function jsonDeserialize($jsonData): JsonDeserializableInterface
{
if (is_string($jsonData)) {
$decodedJsonDataArray = json_decode($jsonData, true);
Expand All @@ -34,7 +37,7 @@ public function jsonDeserialize(array|string $jsonData): JsonDeserializableInter
return $this;
}

public function getStatusCode(): string
public function getStatusCode(): ?string
{
return $this->statusCode;
}
Expand All @@ -47,7 +50,7 @@ public function setStatusCode(string $statusCode): void
/**
* @return OutboxMessage[]
*/
public function getMessages(): array
public function getMessages(): ?array
{
return $this->messages;
}
Expand Down
1 change: 0 additions & 1 deletion src/Dto/Messaging/Inner/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public function setTimestamp(string $timestamp): void
$this->timestamp = $timestamp;
}

#[ArrayShape([self::MESSAGE => "string", self::TIMESTAMP => "string"])]
public function jsonSerialize(): array
{
return [
Expand Down
7 changes: 5 additions & 2 deletions src/Dto/Onboard/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class Authentication implements JsonSerializable, JsonDeserializableInterface
private ?string $certificate = null;


#[ArrayShape([self::TYPE => "string", self::SECRET => "string", self::CERTIFICATE => "string"])]
public function jsonSerialize(): array
{
return [
Expand Down Expand Up @@ -63,7 +62,11 @@ public function setCertificate(string $certificate): void
$this->certificate = $certificate;
}

public function jsonDeserialize(string|array $jsonData): self
/**
* @param string|mixed[] $jsonData
* @return $this
*/
public function jsonDeserialize($jsonData)
{
if (is_string($jsonData)) {
$decodedJsonDataArray = json_decode($jsonData, true);
Expand Down
6 changes: 5 additions & 1 deletion src/Dto/Onboard/AuthorizationToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ public function setExpires(string $expires): void
$this->expires = $expires;
}

public function jsonDeserialize(string|array $jsonData): self
/**
* @param string|mixed[] $jsonData
* @return $this
*/
public function jsonDeserialize($jsonData)
{
if (is_string($jsonData)) {
$decodedJsonDataArray = json_decode($jsonData, true);
Expand Down
7 changes: 7 additions & 0 deletions src/Dto/Onboard/AuthorizationUrlResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ class AuthorizationUrlResult
private ?string $authorizationUrl = null;
private ?string $state = null;

public function __construct(?string $authorizationUrl, ?string $state)
{
$this->authorizationUrl = $authorizationUrl;
$this->state = $state;
}


public function getAuthorizationUrl(): ?string
{
return $this->authorizationUrl;
Expand Down
7 changes: 5 additions & 2 deletions src/Dto/Onboard/ConnectionCriteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class ConnectionCriteria implements JsonSerializable, JsonDeserializableInterfac
private ?string $port = null;
private ?string $clientId = null;

#[ArrayShape([self::CLIENT_ID => "string", self::COMMANDS => "string", self::GATEWAY_ID => "string", self::HOST => "string", self::MEASURES => "string", self::PORT => "string"])]
public function jsonSerialize(): array
{
return [
Expand Down Expand Up @@ -102,7 +101,11 @@ public function setPort(string $port): void
$this->port = $port;
}

public function jsonDeserialize(string|array $jsonData): self
/**
* @param string|mixed[] $jsonData
* @return $this
*/
public function jsonDeserialize($jsonData)
{
if (is_string($jsonData)) {
$decodedJsonDataArray = json_decode($jsonData, true);
Expand Down
8 changes: 5 additions & 3 deletions src/Dto/Onboard/OnboardResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ class OnboardResponse implements JsonSerializable, JsonDeserializableInterface
* Serializes the object data to a simple array
* @return array Array with object data.
*/
#[ArrayShape([self::AUTHENTICATION => Authentication::class, self::CAPABILITY_ALTERNATE_ID => "string",
self::CONNECTION_CRITERIA => ConnectionCriteria::class, self::DEVICE_ALTERNATE_ID => "string", self::SENSOR_ALTERNATE_ID => "string"])]
public function jsonSerialize(): array
{
return [
Expand Down Expand Up @@ -93,7 +91,11 @@ public function setSensorAlternateId(string $sensorAlternateId): void
$this->sensorAlternateId = $sensorAlternateId;
}

public function jsonDeserialize(array|string $jsonData): self
/**
* @param mixed[]|string $jsonData
* @return $this
*/
public function jsonDeserialize($jsonData)
{
if (is_string($jsonData)) {
$decodedJsonDataArray = json_decode($jsonData, true);
Expand Down
19 changes: 13 additions & 6 deletions src/Dto/Onboard/VerificationResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class VerificationResponse implements JsonSerializable, JsonDeserializableInterf
* Serializes the object data to a simple array
* @return array Array with object data.
*/
#[ArrayShape([self::ACCOUNT_ID => "string"])]
public function jsonSerialize(): array
{
return [
Expand All @@ -40,18 +39,26 @@ public function setAccountId(string $accountId): void
$this->accountId = $accountId;
}

public function jsonDeserialize(array|string $jsonData): self
/**
* @param mixed[]|string $jsonData
* @return $this
*/
public function jsonDeserialize($jsonData)
{
if (is_string($jsonData)) {
$decodedJsonDataArray = json_decode($jsonData, true);
} else {
$decodedJsonDataArray = $jsonData;
}
foreach ($decodedJsonDataArray as $fieldName => $fieldValue) {
$this->accountId = match ($fieldName) {
self::ACCOUNT_ID => $fieldValue,
default => throw new JsonException("Unknown field '$fieldName' for class '" . get_class($this) . "'.", ErrorCodes::UNKNOWN_FIELD_IN_JSON_DATA),
};
switch ($fieldName) {
case self::ACCOUNT_ID:
$this->accountId = $fieldValue;
break;
default:
throw new JsonException("Unknown field '$fieldName' for class '" . get_class($this) . "'.", ErrorCodes::UNKNOWN_FIELD_IN_JSON_DATA);
break;
}
}
return $this;
}
Expand Down
Loading