This is to make it clearer that they're related to converting serialized content back into JSON, rather than stating that things are not representable in JSON. Change-Id: Ic440ac2d05b5ac238a1c0e4821d3f2d858bc3d76
34 lines
864 B
PHP
34 lines
864 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Tests\Json;
|
|
|
|
use MediaWiki\Json\JsonDeserializableTrait;
|
|
use MediaWiki\Json\JsonDeserializer;
|
|
|
|
/**
|
|
* Testing class for JsonDeserializer unit tests.
|
|
*/
|
|
class JsonDeserializableSubClass extends JsonDeserializableSuperClass {
|
|
use JsonDeserializableTrait;
|
|
|
|
private $subClassField;
|
|
|
|
public function __construct( $superClassFieldValue, $subClassFieldValue ) {
|
|
parent::__construct( $superClassFieldValue );
|
|
$this->subClassField = $subClassFieldValue;
|
|
}
|
|
|
|
public function getSubClassField() {
|
|
return $this->subClassField;
|
|
}
|
|
|
|
public static function newFromJsonArray( JsonDeserializer $deserializer, array $json ) {
|
|
return new self( $json['super_class_field'], $json['sub_class_field'] );
|
|
}
|
|
|
|
protected function toJsonArray(): array {
|
|
return parent::toJsonArray() + [
|
|
'sub_class_field' => $this->getSubClassField()
|
|
];
|
|
}
|
|
}
|