[PHP] Add support to nullable (based on #3493) (#12794)

* [PHP] Add support to nullable (based on PR 3493)

* [AUTOGENERATED] update samples
This commit is contained in:
Thomas Hansen
2022-07-11 18:00:39 +02:00
committed by GitHub
parent 20420e5e14
commit cd48db43b4
47 changed files with 4258 additions and 129 deletions

View File

@@ -98,7 +98,7 @@ class ObjectSerializer
}
}
}
if ($value !== null) {
if (($data::isNullable($property) && $data->isNullableSetToNull($property)) || $value !== null) {
$values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]);
}
}
@@ -469,7 +469,15 @@ class ObjectSerializer
foreach ($instance::openAPITypes() as $property => $type) {
$propertySetter = $instance::setters()[$property];
if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) {
if (!isset($propertySetter)) {
continue;
}
if (!isset($data->{$instance::attributeMap()[$property]})) {
if ($instance::isNullable($property)) {
$instance->$propertySetter(null);
}
continue;
}