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

The argument of array_key_exists cannot be null #798

Merged
merged 1 commit into from
Nov 7, 2019

Conversation

baijunyao
Copy link
Contributor

@baijunyao baijunyao commented Nov 7, 2019

Copy link
Contributor

@ob-stripe ob-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not sure what could cause $this->filters to be null, but more defensive programming can't hurt :)

Thanks for the contribution!

@ob-stripe ob-stripe merged commit e1bc86b into stripe:master Nov 7, 2019
@baijunyao
Copy link
Contributor Author

  1. For example, I call the all() method of Account
    foreach (\Stripe\Account::all()->autoPagingIterator() as $payout) {
        var_dump($payout);
    }
  1. lib/ApiOperations/All.php
    The all() method calls the setFilters() method
    public static function all($params = null, $opts = null)
    {
        self::_validateParams($params);
        $url = static::classUrl();

        list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
        if (!($obj instanceof \Stripe\Collection)) {
            throw new \Stripe\Exception\UnexpectedValueException(
                'Expected type ' . \Stripe\Collection::class . ', got "' . get_class($obj) . '" instead.'
            );
        }
        $obj->setLastResponse($response);
        $obj->setFilters($params);
        return $obj;
    }
  • $params = null.
  • $obj->setFilters($params);
  1. lib/Collection.php
    public function setFilters($filters)
    {
        $this->filters = $filters;
    }

$this->filters = null

@ob-stripe
Copy link
Contributor

Ah, I see. Thanks for the explanation (and the patch!).

@baijunyao
Copy link
Contributor Author

baijunyao commented Nov 9, 2019

So, I think #796 may need to be merged, this completely solves the problem that filters maybe null, Otherwise we don't know where it will be called in a place where filters is not allowed to be null.

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

Successfully merging this pull request may close these issues.

3 participants