-
Notifications
You must be signed in to change notification settings - Fork 850
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
Services bugfix: convert nested null params to empty strings #933
Conversation
d583711
to
d5bda98
Compare
static::assertTrue(null !== $result['foo']['bar']); | ||
static::assertTrue(1 === $result['foo']['baz']); | ||
|
||
$result = \Stripe\Service\AbstractService::formatParams(['foo' => ["bar", null, null, "baz"]]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about passing
[
'email' => null,
'invoice_settings' => [
'default_payment_method' => 'null',
],
]
As in, this method didn't seem recurring or able to handle non top-level params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite follow -- this PR adds a recursive call https://github.com/stripe/stripe-php/pull/933/files#diff-d6b577df0148860a08e6dfb3025bd0d0R52
and this test case covers non top-level params -- everything is nested one level under "foo".
ptal @remi-stripe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving though I'd feel better if we waited for @ob-stripe's +1 to be safe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, though I'd prefer not to make the method public. You can use \ReflectionMethod
to invoke protected or private methods in tests (e.g. https://github.com/stripe/stripe-php/blob/master/tests/Stripe/StripeObjectTest.php#L28-L29). Feel free to leave as is though.
Thanks! Made private |
Formatting error is causing CI to fail, ptal @richardm-stripe |
Fixed, sorry
ptal @ob-stripe
…On Fri, May 15, 2020 at 1:26 PM Olivier Bellone ***@***.***> wrote:
Formatting error is causing CI to fail, ptal @richardm-stripe
<https://github.com/richardm-stripe>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#933 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMTZ7O3XDKDU6ATHRLL23YDRRV3LVANCNFSM4NBTPUCA>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
With PHP services, unlike the singlon API, sending
null
on a method's params is translated to an empty string when it is sent to the API, to cause the API to unset that field. This was only working properly for top-level parameters. This PR causes the substitution to take place recursively, and handle null properly inside arrays (both associative and non-associative).