Skip to content

Commit

Permalink
Merge pull request #2 from frankbv/jsonSerialize
Browse files Browse the repository at this point in the history
Fix jsonSerialize typehint deprecations in PHP 8.1
  • Loading branch information
gnoddep authored Jul 30, 2022
2 parents d47b7ff + 0a32cf9 commit 0dd9e4d
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 49 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"phpunit/phpunit": "^9.5"
},
"require": {
"ext-json": "*",
"rybakit/msgpack": "^0.9.0"
},
"suggest": {
Expand Down
5 changes: 1 addition & 4 deletions src/Buybrain/Nervus/Adapter/Config/AdapterConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ public function __construct($codec, $adapterType, ExtraAdapterConfig $extra = nu
$this->extra = $extra;
}

/**
* @return array
*/
function jsonSerialize()
function jsonSerialize(): array
{
return [
'codec' => $this->codec,
Expand Down
5 changes: 1 addition & 4 deletions src/Buybrain/Nervus/Adapter/Config/SignalAdapterConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ public function __construct($interval, $priority)
$this->priority = (int)$priority;
}

/**
* @return array
*/
function jsonSerialize()
function jsonSerialize(): array
{
return [
'interval' => $this->interval,
Expand Down
5 changes: 1 addition & 4 deletions src/Buybrain/Nervus/Adapter/Config/TypedAdapterConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ public function __construct(array $entityTypes = null)
$this->entityTypes = $entityTypes;
}

/**
* @return array
*/
function jsonSerialize()
function jsonSerialize(): array
{
return [
'entityTypes' => $this->entityTypes,
Expand Down
5 changes: 1 addition & 4 deletions src/Buybrain/Nervus/Adapter/Message/AbstractResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ public static function fromArray(array $data, StructMapper $mapper)
return new static($data['status'], $data['error']);
}

/**
* @return array
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
return [
'status' => $this->status,
Expand Down
5 changes: 1 addition & 4 deletions src/Buybrain/Nervus/Adapter/Message/ReadRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ public static function fromArray(array $data, StructMapper $mapper)
return new self($ids);
}

/**
* @return array
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
return ['ids' => $this->ids];
}
Expand Down
5 changes: 1 addition & 4 deletions src/Buybrain/Nervus/Adapter/Message/ReadResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ public static function fromArray(array $data, StructMapper $mapper)
return $res;
}

/**
* @return array
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
return array_merge(parent::jsonSerialize(), ['entities' => $this->entities]);
}
Expand Down
5 changes: 1 addition & 4 deletions src/Buybrain/Nervus/Adapter/Message/Signal.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ public static function fromArray(array $data, StructMapper $mapper)
}, $data['ids']));
}

/**
* @return array
*/
function jsonSerialize()
function jsonSerialize(): array
{
return [
'ids' => $this->ids,
Expand Down
5 changes: 1 addition & 4 deletions src/Buybrain/Nervus/Adapter/Message/SignalAckRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ public static function fromArray(array $data)
return new self($data['ack']);
}

/**
* @return array
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
return ['ack' => $this->ack];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Buybrain/Nervus/Adapter/Message/SignalRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SignalRequest implements JsonSerializable
/**
* @return array
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
return [];
}
Expand Down
5 changes: 1 addition & 4 deletions src/Buybrain/Nervus/Adapter/Message/SignalResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ public static function fromArray(array $data, StructMapper $mapper)
return $res;
}

/**
* @return array
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
return array_merge(parent::jsonSerialize(), ['signal' => $this->signal]);
}
Expand Down
5 changes: 1 addition & 4 deletions src/Buybrain/Nervus/Adapter/Message/WriteRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ public static function fromArray(array $data, StructMapper $mapper)
return new self($entities);
}

/**
* @return array
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
return [
'entities' => $this->entities,
Expand Down
5 changes: 1 addition & 4 deletions src/Buybrain/Nervus/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ public function getData()
return $this->data;
}

/**
* return array
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
return [
'id' => $this->id,
Expand Down
5 changes: 1 addition & 4 deletions src/Buybrain/Nervus/EntityId.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ public function getId()
return $this->id;
}

/**
* @return array
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
return [
'type' => $this->type,
Expand Down

0 comments on commit 0dd9e4d

Please sign in to comment.