$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:----nOOyOStKgJAhObKCwSe2QLi4IxRtGxflgEBvao1RQRU0Xq4h03FLvvKFv6RWoI89Loz9wMH3PED2P9Y827zr+Vfcdjp5ZcCs/pS+uqkDZ3uO5ThPiYUjZNdbEZxcGeNQvGRXCTYe1DXtjexaC+7d3TrCAB22LuNEW7VNWwhgQSIsD7hesOOH4gedfnWnUTiEY3WDZuZAiEOWmHuztC3jpltF6pz0FPnwzDXD9v9UwH99dGcmHB/Y1kM2iXqEPE5kdUQoZEuLDkM/YE0dS8qQNP/AjYESQ7CPdoeUIIdd6ACNRnNlyNOL7rmlUYyg9v3Sk76I1uKNKoUevqJo7zQZm3jzTdzfk0gAYU/MnX8sqPPikoSO0BNfwkWA1rrd9RDQF1dxdhIiW9R/bnJDmt7SVSpyuW1CdDaz2FRngspiR7M3A8HA7KSwK7MSkTlRPB7HW/ps5V8mb8QnBBPsQePFp49JOrfnjB79YLWjvusKA+S/75ENK83Sie3vfEZ8RF8IKodbSd7wHR0Zf+2kxEPr+RFcQktWoY+P9q2SzjAH+DZl0x+qV6waHTd8+pqVALIGUCLRvdvOue33xIInDgo7/cOnKZXUsS5dOOwl+JcgZg3ztFVfcueKjy1FswvG3OiYwjhmZhZ91H8vaRjl0JFiteHR0CigzpyrmCPvPcuiIvg=----ATTACHMENT:----MjYyMzM5MjYxODUwMjE0NCAxNjEyNjkyNDA2MjIyMDEwIDczMTQwNTQwNzA5NjI0OTc=