Add typing to jsonSerialize

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2022-02-24 16:43:37 +01:00
parent 9fa12f44ea
commit 46f2d448ab
8 changed files with 15 additions and 21 deletions

View File

@@ -23,7 +23,9 @@
namespace OCA\Deck\Db;
class RelationalObject implements \JsonSerializable {
use JsonSerializable;
class RelationalObject implements JsonSerializable {
protected $primaryKey;
protected $object;
@@ -38,7 +40,7 @@ class RelationalObject implements \JsonSerializable {
$this->object = $object;
}
public function jsonSerialize() {
public function jsonSerialize(): array {
return array_merge(
['primaryKey' => $this->primaryKey],
$this->getObjectSerialization()
@@ -51,8 +53,8 @@ class RelationalObject implements \JsonSerializable {
* @throws \Exception
*/
public function getObjectSerialization() {
if ($this->object instanceof \JsonSerializable) {
$this->object->jsonSerialize();
if ($this->object instanceof JsonSerializable) {
return $this->object->jsonSerialize();
} else {
throw new \Exception('jsonSerialize is not implemented on ' . get_class($this));
}