MediaWiki  master
JsonUnserializableTrait.php
Go to the documentation of this file.
1 <?php
22 namespace MediaWiki\Json;
23 
25 
26  public function jsonSerialize(): array {
27  return $this->annotateJsonForDeserialization(
28  $this->toJsonArray()
29  );
30  }
31 
38  private function annotateJsonForDeserialization( array $json ): array {
39  $json[JsonConstants::TYPE_ANNOTATION] = get_class( $this );
40  return $json;
41  }
42 
49  abstract protected function toJsonArray(): array;
50 }
const TYPE_ANNOTATION
Name of the property where the class information is stored.