MediaWiki
master
JsonDeserializableTrait.php
Go to the documentation of this file.
1
<?php
22
namespace
MediaWiki\Json
;
23
24
trait JsonDeserializableTrait {
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
}
51
53
class_alias( JsonDeserializableTrait::class,
'MediaWiki\\Json\\JsonUnserializableTrait'
);
MediaWiki\Json\JsonConstants\TYPE_ANNOTATION
const TYPE_ANNOTATION
Name of the property where the class information is stored.
Definition
JsonConstants.php:34
MediaWiki\Json
Definition
FormatJson.php:23
includes
json
JsonDeserializableTrait.php
Generated on Sun Feb 16 2025 12:24:39 for MediaWiki by
1.10.0