One major difference with what we've had before is that now we actually write class names into the serialization - given that this new mechanism is extencible, we can't establish any kind of mapping of allowed classes. I do not think it's a problem though. Bug: T264394 Change-Id: Ia152f3b76b967aabde2d8a182e3aec7d3002e5ea
35 lines
841 B
PHP
35 lines
841 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Tests\Json;
|
|
|
|
use MediaWiki\Json\JsonUnserializable;
|
|
use MediaWiki\Json\JsonUnserializableTrait;
|
|
use MediaWiki\Json\JsonUnserializer;
|
|
|
|
/**
|
|
* Testing class for JsonUnserializer unit tests.
|
|
* @package MediaWiki\Tests\Json
|
|
*/
|
|
class JsonUnserializableSuperClass implements JsonUnserializable {
|
|
use JsonUnserializableTrait;
|
|
|
|
private $superClassField;
|
|
|
|
public function __construct( string $superClassFieldValue ) {
|
|
$this->superClassField = $superClassFieldValue;
|
|
}
|
|
|
|
public function getSuperClassField(): string {
|
|
return $this->superClassField;
|
|
}
|
|
|
|
public static function newFromJsonArray( JsonUnserializer $unserializer, array $json ) {
|
|
return new self( $json['super_class_field'] );
|
|
}
|
|
|
|
protected function toJsonArray(): array {
|
|
return [
|
|
'super_class_field' => $this->getSuperClassField()
|
|
];
|
|
}
|
|
}
|