Skip to content

Commit

Permalink
Allow passing explicit null values for optional input members (#1542)
Browse files Browse the repository at this point in the history
This makes it easier to define the array literal for input objects as
PHP does not have a syntax sugar for conditional keys in an array
literal. This is consistent with the generated code for value objects.

Even though input objects allow to omit required members in the
constructor shape (as they can be set later by using the setter), the
phpdoc type still does not allow passing null explicitly (even though
the code would deal with it until the validation run) so that static
analysis tools can catch mistakes there. Passing a required member
explicitly is intended to pass a valid value for it and not a
potentially missing one.
  • Loading branch information
stof authored Aug 9, 2023
1 parent 4bcadf6 commit 5f5c69e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Input/GetThingShadowRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class GetThingShadowRequest extends Input
/**
* @param array{
* thingName?: string,
* shadowName?: string,
* shadowName?: null|string,
* '@region'?: string|null,
* } $input
*/
Expand All @@ -45,7 +45,7 @@ public function __construct(array $input = [])
/**
* @param array{
* thingName?: string,
* shadowName?: string,
* shadowName?: null|string,
* '@region'?: string|null,
* }|GetThingShadowRequest $input
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Input/UpdateThingShadowRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final class UpdateThingShadowRequest extends Input
/**
* @param array{
* thingName?: string,
* shadowName?: string,
* shadowName?: null|string,
* payload?: string,
* '@region'?: string|null,
* } $input
Expand All @@ -56,7 +56,7 @@ public function __construct(array $input = [])
/**
* @param array{
* thingName?: string,
* shadowName?: string,
* shadowName?: null|string,
* payload?: string,
* '@region'?: string|null,
* }|UpdateThingShadowRequest $input
Expand Down
4 changes: 2 additions & 2 deletions src/IotDataClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class IotDataClient extends AbstractApi
*
* @param array{
* thingName: string,
* shadowName?: string,
* shadowName?: null|string,
* '@region'?: string|null,
* }|GetThingShadowRequest $input
*
Expand Down Expand Up @@ -84,7 +84,7 @@ public function getThingShadow($input): GetThingShadowResponse
*
* @param array{
* thingName: string,
* shadowName?: string,
* shadowName?: null|string,
* payload: string,
* '@region'?: string|null,
* }|UpdateThingShadowRequest $input
Expand Down

0 comments on commit 5f5c69e

Please sign in to comment.