Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missed return statement for account deauthorize method. Or wrong hinting in phpDoc #485

Closed
fre5h opened this issue Jun 21, 2018 · 2 comments

Comments

@fre5h
Copy link

fre5h commented Jun 21, 2018

Hello. Check this method https://github.com/stripe/stripe-php/blob/master/lib/Account.php#L116
I also copy its body here too

    /**
     * @param array|null $clientId
     * @param array|string|null $opts
     *
     * @return StripeObject Object containing the response from the API.
     */
    public function deauthorize($clientId = null, $opts = null)
    {
        $params = [
            'client_id' => $clientId,
            'stripe_user_id' => $this->id,
        ];
        OAuth::deauthorize($params, $opts);
    }

There is a @return docBlock which says that StripeObject should be returned. But return statement is missed.
This can be fixed in two ways.

First. Remove docBlock, so the method won't return anything

    /**
     * @param array|null $clientId
     * @param array|string|null $opts
     */
    public function deauthorize($clientId = null, $opts = null)
    {
        $params = [
            'client_id' => $clientId,
            'stripe_user_id' => $this->id,
        ];
        OAuth::deauthorize($params, $opts);
    }

Second. Add missed return statement. I think it is better solution

    /**
     * @param array|null $clientId
     * @param array|string|null $opts
     *
     * @return StripeObject Object containing the response from the API.
     */
    public function deauthorize($clientId = null, $opts = null)
    {
        $params = [
            'client_id' => $clientId,
            'stripe_user_id' => $this->id,
        ];
        
        return OAuth::deauthorize($params, $opts);
    }

I'm using stripe/stripe-php": "^6.8" same issue in master branch too.

@ob-stripe
Copy link
Contributor

Hi @fre5h, thanks for the report! I've implemented the second solution in #486.

Note that in practice, there shouldn't be any need to check the returned object (IIRC it only contains the ID of the account anyway). You would simply wrap the call in a try/catch block to ensure that it succeeded.

@ob-stripe
Copy link
Contributor

Released as 6.8.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants