| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Extends the V2RuntimeSchema field encoding coercion to handle two new schema kinds emitted by the code generator: - nullable: unwraps to the inner schema, passing null through unchanged - discriminatedUnion: selects the variant schema by reading the discriminator field's value from the data, then coerces using it Also adds decimal_string request coercion (float/int to string), matching the existing int64_string pattern. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
Tests discriminated union serialization for both request-side (array params with literal discriminator) and response-side (StripeObject construction), covering standalone and inline variants. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds runtime support for additional V2 field-encoding schema kinds so int64/decimal coercion still occurs when fields are wrapped (e.g., nullable or discriminated unions).
Changes:
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| lib/Util/Int64.php | Adds handling for decimal_string, nullable, and discriminatedUnion in request/response coercion paths |
| tests/Stripe/Util/Int64Test.php | Adds coverage for new coercion branches (nullable, discriminated union, decimal) |
| tests/Stripe/DiscriminatedUnionTest.php | Adds tests around discriminated-union request parameter shapes and serialization/deserialization behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
| if ('discriminatedUnion' === $schema['kind'] && isset($schema['discriminator'], $schema['variants'])) { | ||
| if (\is_array($params) && \array_key_exists($schema['discriminator'], $params)) { | ||
| $discriminatorValue = $params[$schema['discriminator']]; | ||
| if (\array_key_exists($discriminatorValue, $schema['variants'])) { | ||
| return self::coerceRequestParams($params, $schema['variants'][$discriminatorValue]); | ||
| } | ||
| } |
| } elseif ('discriminatedUnion' === $encoding['kind'] && isset($encoding['discriminator'], $encoding['variants'])) { | ||
| if (\is_array($value) && \array_key_exists($encoding['discriminator'], $value)) { | ||
| $discriminatorValue = $value[$encoding['discriminator']]; | ||
| if (\array_key_exists($discriminatorValue, $encoding['variants'])) { | ||
| $values = self::coerceResponseValues($values, [$field => $encoding['variants'][$discriminatorValue]]); | ||
| } | ||
| } |
Prevents a TypeError when the discriminator field value is null, an array, or any other non-string type — array_key_exists requires a string or int key. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
…ests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
| Back | FazBrowse Home | New Git URL |
Why?
The sdk-codegen now emits V2RuntimeSchema field encoding schemas that can include two new kinds: nullable and discriminatedUnion. Without handling for these kinds in the PHP runtime, those fields would pass through uncoerced — int64_string fields nested inside a nullable or discriminated union wrapper would not be converted between their wire representation and their PHP type.
What?
See Also
No external links.
Changelog