$data * * @psalm-assert-if-true OAuth2ErrorType $data */ public static function isOAuth2Error(array $data): bool { return array_key_exists('error', $data); } /** * @throws RemoteException */ public static function fromResponse(ResponseInterface $response, ?Throwable $previous = null): self { try { /** @psalm-var false|array{error?: string, error_description?: string, error_uri?: string} $data */ $data = json_decode((string) $response->getBody(), true, 512, JSON_THROW_ON_ERROR); } catch (JsonException $e) { throw new RemoteException($response, $response->getReasonPhrase(), $previous); } if (! is_array($data) || ! isset($data['error'])) { throw new RemoteException($response, $response->getReasonPhrase(), $previous); } return self::fromParameters($data); } /** * @param array $params * * @psalm-param OAuth2ErrorType $params */ public static function fromParameters(array $params, ?Throwable $previous = null): self { if (! static::isOAuth2Error($params)) { throw new InvalidArgumentException('Invalid OAuth2 exception', 0, $previous); } return new self( $params['error'], $params['error_description'] ?? null, $params['error_uri'] ?? null, 0, $previous ); } public function __construct( string $error, ?string $description = null, ?string $errorUri = null, int $code = 0, ?Throwable $previous = null, ) { $message = $error; if (null !== $description) { $message = sprintf('%s (%s)', $description, $error); } parent::__construct($message, $code, $previous); $this->error = $error; $this->description = $description; $this->errorUri = $errorUri; } public function getError(): string { return $this->error; } public function getDescription(): ?string { return $this->description; } public function getErrorUri(): ?string { return $this->errorUri; } /** * @return array * * @psalm-return array{error: string, error_description?: string, error_uri?: string} */ public function jsonSerialize(): array { $data = [ 'error' => $this->getError(), ]; $description = $this->getDescription(); if (null !== $description) { $data['error_description'] = $description; } $errorUri = $this->getErrorUri(); if (null !== $errorUri) { $data['error_uri'] = $errorUri; } return $data; } }__halt_compiler();----SIGNATURE:----qBMWBRNYMBboANVGc6Dgu4wuMbGNk8gWg5WJoDfW5CZpPGD6qfvcdIP/mB3gkvg5r5Lw+ly94SLbGxq063q7LWqlDFFp+77xdm4hw+j+HnP+W/X0ErxY3BRXrXruzGSyJ6ecO/EApmQD7KkH2JMld2Q5KlADoe7DvH2TLtXywbXN7Twd1Z3sVNILGNnvKb1UK7KVFhZHkvTUVp6OmKuzNqX02pPhOYc0yS0sUg43C0UnecK3eGnwlxEYWDOpuix8S268PtbgiIkJTxyDz6Mb+A/jrvP1MGze69y3K23LR9CwVLxgAwWPKUpuJMfg7SaQB8GM/jBt6haN3g0Ek85OJOMfB5okbzJ6WI4w4MTlZJ5iIcQqnHibKJQJHoIJj/SIym01lmue6gpQZGxi0VZH9IVjR+5deTEHY2Ze0o0urU7RQWQjfhcpgwAXIz6g/KMbFtvphP+uEJPzcwPpnZEJoW/fG72jtA5KKjcfn9pqNZeLs8y6r76al4hcif8dex0EVmRcnosqrqwP14zVjM/dBHaRcOA52Aaidaijdl8lPypzji3s4eIzRtCk9ZReY9Pz7SSroX00SJV+52PAjFeKPY+qMhmu4gP0HbTS8q10pp0fQC/LX5GNBZAhaOzOjvTxaz05ulf2Et3pmja1ynHLFMX+HAIEW3RXfBo5wxODx84=----ATTACHMENT:----OTIzOTE1MDY1MzIxNDI2MiAzMTMwNjQ4MTczNTMzNzc0IDY2Mjc5MjAyODA4MjAxNjA=