MediaWiki master
JsonDeserializableTrait.php
Go to the documentation of this file.
1<?php
8namespace MediaWiki\Json;
9
12
13 public function jsonSerialize(): array {
14 return $this->annotateJsonForDeserialization(
15 $this->toJsonArray()
16 );
17 }
18
25 private function annotateJsonForDeserialization( array $json ): array {
26 $json[JsonConstants::TYPE_ANNOTATION] = get_class( $this );
27 return $json;
28 }
29
36 abstract protected function toJsonArray(): array;
37}
38
40class_alias( JsonDeserializableTrait::class, 'MediaWiki\\Json\\JsonUnserializableTrait' );
const TYPE_ANNOTATION
Name of the property where the class information is stored.