|null $params @since 2024-11-05 */ public function __construct( string $method, string $jsonrpc, ?array $params = null ) { parent::__construct($method, $params); $this->jsonrpc = $jsonrpc; } /** * Creates an instance from an array. * * @param array{ * method: string, * params?: array|null, * jsonrpc: '2.0' * } $data * @phpstan-param array $data * @return self */ public static function fromArray(array $data): self { self::assertRequired($data, ['method', 'jsonrpc']); /** @var '2.0' $jsonrpc */ $jsonrpc = self::asString($data['jsonrpc']); return new self( self::asString($data['method']), $jsonrpc, self::asArrayOrNull($data['params'] ?? null) ); } /** * Converts the instance to an array. * * @return array */ public function toArray(): array { $result = parent::toArray(); $result['jsonrpc'] = $this->jsonrpc; return $result; } /** * @return '2.0' */ public function getJsonrpc(): string { return $this->jsonrpc; } }