Repository: appwrite/appwrite
File: src/Appwrite/Auth/OAuth2/Slack.php (PHP)

Code before:
    {
        return 'https://slack.com/oauth/v2/authorize?' . \http_build_query([
            'client_id' => $this->appID,
            'user_scope' => \implode(' ', $this->getScopes()),
            'redirect_uri' => $this->callback,
            'state' => \json_encode($this->state)
        ]);
    }

    /**
     * @param string $code
     *
     * @return array
     */
    protected function getTokens(string $code): array
    {
        if (empty($this->tokens)) {
            $this->tokens = \json_decode($this->request(
                'GET',
                'https://slack.com/api/oauth.v2.access?' . \http_build_query([
                    'client_id' => $this->appID,
                    'client_secret' => $this->appSecret,
                    'code' => $code,
                    'redirect_uri' => $this->callback
                ])
            ), true)['authed_user'];
        }

        return $this->tokens;
    }

    /**
     * @param string $refreshToken
     *
     * @return array
     */
    public function refreshTokens(string $refreshToken): array
    {
        $this->tokens = \json_decode($this->request(
            'GET',
            'https://slack.com/api/oauth.v2.access?' . \http_build_query([
                'client_id' => $this->appID,
                'client_secret' => $this->appSecret,
                'refresh_token' => $refreshToken,
                'grant_type' => 'refresh_token'
            ])
        ), true)['authed_user'];

        if (empty($this->tokens['refresh_token'])) {
            $this->tokens['refresh_token'] = $refreshToken;
        }

Review comment (suggestion):
Accessing like this is dangerous and can throw an exception leading to a 500 error. Let's be a bit more defensive and use `??`

Code after:
    {
        return 'https://slack.com/oauth/v2/authorize?' . \http_build_query([
            'client_id' => $this->appID,
            'user_scope' => \implode(' ', $this->getScopes()),
            'redirect_uri' => $this->callback,
            'state' => \json_encode($this->state)
        ]);
    }

    /**
     * @param string $code
     *
     * @return array
     */
    protected function getTokens(string $code): array
    {
        if (empty($this->tokens)) {
            $this->tokens = \json_decode($this->request(
                'GET',
                'https://slack.com/api/oauth.v2.access?' . \http_build_query([
                    'client_id' => $this->appID,
                    'client_secret' => $this->appSecret,
                    'code' => $code,
                    'redirect_uri' => $this->callback
                ])
            ), true)['authed_user'] ?? [];
        }

        return $this->tokens;
    }

    /**
     * @param string $refreshToken
     *
     * @return array
     */
    public function refreshTokens(string $refreshToken): array
    {
        $this->tokens = \json_decode($this->request(
            'GET',
            'https://slack.com/api/oauth.v2.access?' . \http_build_query([
                'client_id' => $this->appID,
                'client_secret' => $this->appSecret,
                'refresh_token' => $refreshToken,
                'grant_type' => 'refresh_token'
            ])
        ), true)['authed_user'] ?? [];

        if (empty($this->tokens['refresh_token'])) {
            $this->tokens['refresh_token'] = $refreshToken;
        }