JSONRPC 1.0.0

Request extends Request
in package
uses SerializerAware, JsonRpcVersionAware

Table of Contents

Properties

$content_type  : mixed
$currentIdCounter  : mixed
$currentIdPrefix  : mixed
$id  : mixed
$jsonrpc_version  : string|null
$paramnames  : array<string|int, string>
$serializer  : mixed

Methods

__construct()  : mixed
addParam()  : bool
getCharsetEncoder()  : Charset
Reimplemented to make us use the correct parser type.
getJsonRpcVersion()  : string|null
getParamName()  : string
getParser()  : Parser
Reimplemented to make us use the correct parser type.
getSerializer()  : mixed
id()  : mixed
parseResponse()  : Response|true
Parse the json-rpc response contained in the string $data and return a Response object.
setJsonRpcVersion()  : void
setSerializer()  : mixed
generateId()  : string|int

Properties

$content_type

protected mixed $content_type = 'application/json'

$currentIdCounter

protected static mixed $currentIdCounter = 1

$currentIdPrefix

protected static mixed $currentIdPrefix = ''

$paramnames

protected array<string|int, string> $paramnames = array()

Methods

__construct()

public __construct(string $methodName[, array<string|int, Value$params = array() ][, mixed $id = null ][, null|string $jsonrpcVersion = null ]) : mixed
Parameters
$methodName : string

the name of the method to invoke

$params : array<string|int, Value> = array()

array of parameters to be passed to the method (Value objects). For json-rpc 2.0 calls, the array keys should either be all consecutive integers starting at 0, or be all strings, in which case the named-parameters calling convention will be used instead of the positional parameters one. For json-rpc 1.0 calls, the array keys get discarded, as only positional params are supported by the protocol. Note that \PhpXmlRpc\Value of type DateTime and Base64 will be serialized as json strings, but not decoded into the correct type at the receiving end.

$id : mixed = null

the id of the json-rpc request. A NULL value is allowed, in which case a unique id will be generated. To send notifications, use the Notification class instead.

$jsonrpcVersion : null|string = null

pass either PhpJsonRpc::VERSION_2_0 or PhpJsonRpc::VERSION_1_0 to force a value. If not set, the lib default value (set in PhpJsonRpc::$defaultJsonrpcVersion) will be used

addParam()

public addParam(mixed $param[, string|null $name = null ]) : bool
Parameters
$param : mixed
$name : string|null = null

Either all params should have a name, or none of them

Return values
bool

getCharsetEncoder()

Reimplemented to make us use the correct parser type.

public getCharsetEncoder() : Charset
Return values
Charset

getJsonRpcVersion()

public getJsonRpcVersion() : string|null
Return values
string|null

NULL means let the global var PhpJsonRpc::$defaultJsonRpcVersion decide

getParamName()

public getParamName(int $i) : string
Parameters
$i : int
Return values
string

A string is returned, as long as only string keys are used in the constructor and addParam calls. Does not check if the index is oyt of bounds.

getParser()

Reimplemented to make us use the correct parser type.

public getParser() : Parser
Return values
Parser

parseResponse()

Parse the json-rpc response contained in the string $data and return a Response object.

public parseResponse([string $data = '' ][, bool $headersProcessed = false ][, string $returnType = Parser::RETURN_JSONRPCVALS ]) : Response|true
Parameters
$data : string = ''

the json-rpc response, possibly including http headers

$headersProcessed : bool = false

when true prevents parsing HTTP headers for interpretation of content-encoding and consequent decoding

$returnType : string = Parser::RETURN_JSONRPCVALS

decides return type, i.e. content of response->value(). Either 'jsonrpcvals', 'json' or 'phpvals'

Tags
todo

move more of this parsing into the parent class (split method in smaller ones)

todo

throw when $returnType == 'xmlrpcvals', 'epivals' or 'xml'

todo

we should check that the received Id is the same s the one sent

Return values
Response|true

true when notifications are sent (and the server returns an http response with no body)

setJsonRpcVersion()

public setJsonRpcVersion(string|null $jsonrpcVersion) : void
Parameters
$jsonrpcVersion : string|null

Use NULL to let the global var PhpJsonRpc::$defaultJsonRpcVersion decide

setSerializer()

public static setSerializer(mixed $serializer) : mixed
Parameters
$serializer : mixed

generateId()

protected generateId() : string|int
Return values
string|int

        
On this page

Search results