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

Allow NULL as valid parameter for isRetryableServerError #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

artfulrobot
Copy link

When there was a server error that caused GoCardless API requests to fail, the GC library was failing to handle the error correctly due to a mistake in the function signature.

I was getting errors like this:

PHP Fatal error: Uncaught TypeError: Argument 1 passed to GoCardlessPro\RetryMiddlewareFactory::isRetryableServerError() must be an instance of GuzzleHttp\Psr7\Response, null given, called in vendor/gocardless/gocardless-pro/lib/RetryMiddlewareFactory.php on line 40 and defined in vendor/gocardless/gocardless-pro/lib/RetryMiddlewareFactory.php:88

The problem was that calling that method with an argument whose value is NULL is not allowed by the function signature.

This PR adds a ? before the type hint, which fixes the problem, the code is now valid and when circumstances arise (like network failures) the error can be properly handled and reported.

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

Successfully merging this pull request may close these issues.

1 participant