Skip to content

Commit

Permalink
Merge pull request #11 from pmzandbergen/patch-1
Browse files Browse the repository at this point in the history
Fix: PHP 8.1 JsonSerializable compatibility
  • Loading branch information
bramstroker authored Aug 11, 2022
2 parents b02d66a + 765f7bc commit f9c7932
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Model/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ public function count()
* which is a value of any type other than a resource.
* @since 5.4.0
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
if ($this->key !== null) {
return [$this->key => $this->elements];
}
return $this->elements;
}
}
}
3 changes: 2 additions & 1 deletion src/Model/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ public function __toString(): string
* which is a value of any type other than a resource.
* @since 5.4.0
*/
function jsonSerialize()
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
$data = [
'email_address' => $this->emailAddress,
Expand Down
1 change: 1 addition & 0 deletions src/Model/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ public function addDetailsView(DetailsView $detailsView)
* which is a value of any type other than a resource.
* @since 5.4.0
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
$data = [
Expand Down
3 changes: 2 additions & 1 deletion src/Model/Order/DetailsView.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public function setDateFormat(string $dateFormat)
* which is a value of any type other than a resource.
* @since 5.4.0
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
$data = ['display_as' => $this->displayAs];
Expand All @@ -123,4 +124,4 @@ public function jsonSerialize()

return $data;
}
}
}
3 changes: 2 additions & 1 deletion src/Model/SearchResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ public function __construct(Collection $customerCollection, Collection $orderCol
* which is a value of any type other than a resource.
* @since 5.4.0
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return [
'customers' => $this->customerCollection,
'orders' => $this->orderCollection
];
}
}
}

0 comments on commit f9c7932

Please sign in to comment.