StatelessResult
FinalYes
One modern-era answer, paired with the HTTP status that carries it.
SEP-2575 fixes specific statuses to specific JSON-RPC error codes, so the status is part of the answer rather than something the transport re-derives.
Tags
Table of Contents
Properties
- $frames : Closure|null
- $httpStatus : int
- $message : MessageInterface|null
- $body : array<string|int, mixed>|null
- $bodyless : bool
- $id : string|int|null
Methods
- empty() : self
- A status with no body — what a notification gets, since it has no id to correlate a JSON-RPC message against.
- error() : self
- isEmpty() : bool
- isError() : bool
- isStream() : bool
- ok() : self
- A successful answer whose body the wire codec has already stamped — a plain array, since no result class models the fields it added.
- stream() : self
- A long-lived answer delivered as frames — today only `subscriptions/listen`. Deferred, since the frames are produced over the life of the connection.
- toJson() : string
- __construct() : mixed
Properties
$frames read-only
public
Closure|null
$frames
= null
$httpStatus read-only
public
int
$httpStatus
$message read-only
public
MessageInterface|null
$message
$body read-only
private
array<string|int, mixed>|null
$body
= null
$bodyless read-only
private
bool
$bodyless
= false
$id read-only
private
string|int|null
$id
= null
Methods
empty()
A status with no body — what a notification gets, since it has no id to correlate a JSON-RPC message against.
public
static empty(int $httpStatus) : self
Parameters
- $httpStatus : int
Return values
selferror()
public
static error(Error $error, int $httpStatus) : self
Parameters
- $error : Error
- $httpStatus : int
Return values
selfisEmpty()
public
isEmpty() : bool
Return values
boolisError()
public
isError() : bool
Return values
boolisStream()
public
isStream() : bool
Return values
boolok()
A successful answer whose body the wire codec has already stamped — a plain array, since no result class models the fields it added.
public
static ok(string|int $id, array<string, mixed> $body) : self
Parameters
- $id : string|int
- $body : array<string, mixed>
Return values
selfstream()
A long-lived answer delivered as frames — today only `subscriptions/listen`. Deferred, since the frames are produced over the life of the connection.
public
static stream(callable(): Generator<string|int, mixed> $frames) : self
Parameters
- $frames : callable(): Generator<string|int, mixed>
Return values
selftoJson()
public
toJson() : string
Return values
string__construct()
private
__construct(MessageInterface|null $message, int $httpStatus[, callable(): Generator<string|int, mixed>|null $frames = null ][, array<string, mixed>|null $body = null ][, string|int|null $id = null ][, bool $bodyless = false ]) : mixed
Parameters
- $message : MessageInterface|null
- $httpStatus : int
- $frames : callable(): Generator<string|int, mixed>|null = null
-
set instead of $message when the answer is a stream
- $body : array<string, mixed>|null = null
-
a result body already through the wire codec
- $id : string|int|null = null
- $bodyless : bool = false