Skip to content

Commit d78fdf6

Browse files
authored
Merge pull request #187 from maxmind/greg/fix-json-serialize-return-type
Update jsonSerialize return type. Closes #185
2 parents a184294 + 50bfb46 commit d78fdf6

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
CHANGELOG
22
=========
33

4+
2.13.0
5+
-------------------
6+
7+
* The return types on the `jsonSerialize` implementations have been remove
8+
to that they do not conflict with `JsonSerializable::jsonSerialize` on PHP
9+
8+. Reported by Gokul Hegde. GitHub #185.
10+
411
2.12.2 (2021-11-30)
512
-------------------
613

src/Model/AbstractModel.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@ public function __isset(string $attr): bool
6161
return $attr !== 'instance' && isset($this->{$attr});
6262
}
6363

64-
public function jsonSerialize(): array
64+
/**
65+
* @return mixed data that can be serialized by json_encode
66+
*/
67+
// We don't specify a return type here as PHP 8 has "mixed" as the return
68+
// type for "JsonSerializable::jsonSerialize", but PHP 7 doesn't support
69+
// "mixed".
70+
public function jsonSerialize()
6571
{
6672
return $this->raw;
6773
}

src/Record/AbstractRecord.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ private function validAttribute(string $attr): bool
6060
return \in_array($attr, $this->validAttributes, true);
6161
}
6262

63-
public function jsonSerialize(): ?array
63+
/**
64+
* @return mixed data that can be serialized by json_encode
65+
*/
66+
// We don't specify a return type here as PHP 8 has "mixed" as the return
67+
// type for "JsonSerializable::jsonSerialize", but PHP 7 doesn't support
68+
// "mixed".
69+
public function jsonSerialize()
6470
{
6571
return $this->record;
6672
}

0 commit comments

Comments
 (0)