MediaWiki REL1_39
MediaWiki\Json\JsonUnserializer Interface Reference
Inheritance diagram for MediaWiki\Json\JsonUnserializer:

Public Member Functions

 unserialize ( $json, string $expectedClass=null)
 Restore an instance of simple type or JsonUnserializable subclass from the JSON serialization.
 
 unserializeArray (array $array)
 Helper to unserialize an array of JsonUnserializable instances or simple types.
 

Detailed Description

Definition at line 33 of file JsonUnserializer.php.

Member Function Documentation

◆ unserialize()

MediaWiki\Json\JsonUnserializer::unserialize ( $json,
string $expectedClass = null )

Restore an instance of simple type or JsonUnserializable subclass from the JSON serialization.

It supports passing array/object to allow manual decoding of the JSON string if needed.

Note
JSON objects are unconditionally unserialized as PHP associative arrays and not as instances of \stdClass.

@phpcs:ignore MediaWiki.Commenting.FunctionComment.ObjectTypeHintParam

Parameters
array | string | object$json
string | null$expectedClassWhat class to expect in unserialization. If null, no expectation. Must be a descendant of JsonUnserializable.
Exceptions
InvalidArgumentExceptionif the passed $json can't be unserialized.
Returns
mixed

Implemented in MediaWiki\Json\JsonCodec.

◆ unserializeArray()

MediaWiki\Json\JsonUnserializer::unserializeArray ( array $array)

Helper to unserialize an array of JsonUnserializable instances or simple types.

Parameters
array$array
Returns
array

Implemented in MediaWiki\Json\JsonCodec.


The documentation for this interface was generated from the following file: