JsonCodec
Interfaces to serialize and deserialize PHP objects to/from JSON
Loading...
Searching...
No Matches
Wikimedia\JsonCodec\JsonStdClassCodec Class Reference

This is a simple class codec used for stdClass objects. More...

+ Inheritance diagram for Wikimedia\JsonCodec\JsonStdClassCodec:

Public Member Functions

 toJsonArray ( $obj)
 Returns a JSON array representing the contents of the given object, that can be deserialized with the corresponding newFromJsonArray() method, using a ::toJsonArray() method on the object itself.
 
 newFromJsonArray (string $className, array $json)
 Creates a new instance of the given class and initializes it from the $json array, using a static method on $className.
 
 jsonClassHintFor (string $className, string $keyName)
 Returns null, to indicate no type hint for any properties in the stdClass value being encoded.
 

Static Public Member Functions

static getInstance ()
 Return a singleton instance of this stdClass codec.
 

Detailed Description

This is a simple class codec used for stdClass objects.

Member Function Documentation

◆ getInstance()

static Wikimedia\JsonCodec\JsonStdClassCodec::getInstance ( )
static

Return a singleton instance of this stdClass codec.

Returns
JsonStdClassCodec a singleton instance of this class

◆ jsonClassHintFor()

Wikimedia\JsonCodec\JsonStdClassCodec::jsonClassHintFor ( string $className,
string $keyName )

Returns null, to indicate no type hint for any properties in the stdClass value being encoded.

Parameters
class-string<T>$className
string$keyName
Returns
null Always returns null

Implements Wikimedia\JsonCodec\JsonClassCodec.

◆ newFromJsonArray()

Wikimedia\JsonCodec\JsonStdClassCodec::newFromJsonArray ( string $className,
array $json )

Creates a new instance of the given class and initializes it from the $json array, using a static method on $className.

Parameters
class-string<T>$className
array$json
Returns
T @inheritDoc @phan-template T

Implements Wikimedia\JsonCodec\JsonClassCodec.

◆ toJsonArray()

Wikimedia\JsonCodec\JsonStdClassCodec::toJsonArray ( $obj)

Returns a JSON array representing the contents of the given object, that can be deserialized with the corresponding newFromJsonArray() method, using a ::toJsonArray() method on the object itself.

Parameters
object$objAn object of the type handled by this JsonClassCodec
Returns
array A Json representation of the object. @inheritDoc
See also
JsonCodecableTrait

Implements Wikimedia\JsonCodec\JsonClassCodec.


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