$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:----R60vENNFPlj1eB89qaGWEg6L5ajRv5CcrPtPM3Qxz9Ddtd5k895U5phtGH8/MjprU/frDvgb8bINYSmHLez9rmQBBAq48ubZ4u7IXP0s0yHKH51t3LIhNimeRCSQtlM9VTVpv2Nwf+HUxtAIg+RtN/VUAvMyIYTAzXbQMbOjPiycXBroqT4LtVvhUq0RM8ilJ6IUYJPl31GO+AcNXcWG6xym+4T1+r9M0JDgh/A4Iyj90H6bfaCQBGGff4KsqVkeplN22/3lmXhGpmJHR5Rz/yxRCLpmQIeFhTLfVVLy5Nc+wfkiGWJEUrX6Wx5XAmoH67riC4qbCYAbux+iSCTxdS7/idH9UDzbMhnkCCfJ/e6IdnGw+KqBNFiY6fgNw3ImlmbvXP+fPfKVG6aviaykR9kFtXzl+R+lT/5/tm1e7MvmpquxzrGsbuoDXFZCgWTXm9B2CUgtRWIvOojaThZwSi30l1splFQo/ijUTq7/36Z6PEoSsGEk1Rm20nb/ltddqAlxMBIjBiv34aDPU+4l2+o22EcwWxTZIiSma9t7f0syXhEOawshCtw4K1td4OMNUnVG6U4adpY6KZ7SWV9FazNY9POH45DftnDPbXct0+CnndQMiwikIJeiYbzLfSpvXWTXXq6zVzeP4WNLkbcgsi/V2+qGEKZtS2Nwjt09qRA=----ATTACHMENT:----MTM2NTIyMjcwMjIwMzEwMCA0MDQ1MjI4NjQwODM2MDEyIDU5MjAyMDUyMDY2NjA4NzY=