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