Skip to content

Commit

Permalink
Default to get String values
Browse files Browse the repository at this point in the history
  • Loading branch information
Microsoft Graph DevX Tooling authored and Microsoft Graph DevX Tooling committed Dec 2, 2024
1 parent 50de6be commit a11a427
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ private string GetDeserializationMethodName(CodeTypeBase propType, CodeMethod me
if (currentType.TypeDefinition is null)
{
//Set the parseNodeMethod to the appropriate method for the collection of primitive values
parseNodeMethod = $"getCollectionOfPrimitiveValues()";
parseNodeMethod = $"getStringValue()";
}
// else if (conventions.PrimitiveTypes.Contains(currentType.TypeDefinition.Name.ToLowerInvariant()))
// {
Expand Down Expand Up @@ -932,15 +932,7 @@ private void WriteFactoryMethodBodyForIntersectionModel(CodeMethod codeElement,
{
var deserializationMethodName = $"{ParseNodeVarName}->{GetDeserializationMethodName(propertyType, codeElement)}";
writer.StartBlock($"{(includeElse ? "} else " : string.Empty)}if ({deserializationMethodName} !== null) {{");
if (deserializationMethodName.Contains("getCollectionOfPrimitiveValues", StringComparison.Ordinal))
{
writer.WriteLine($"{ResultVarName}->{property.Setter!.Name.ToFirstCharacterLowerCase()}({ParseNodeVarName}->getStringValue());");
}
else
{
writer.WriteLine($"{ResultVarName}->{property.Setter!.Name.ToFirstCharacterLowerCase()}({deserializationMethodName});");
}

writer.WriteLine($"{ResultVarName}->{property.Setter!.Name.ToFirstCharacterLowerCase()}({deserializationMethodName});");
writer.DecreaseIndent();
}
if (!includeElse)
Expand Down Expand Up @@ -1011,14 +1003,7 @@ private void WriteFactoryMethodBodyForUnionModelForUnDiscriminatedTypes(CodeMeth
{
var serializationMethodName = $"{ParseNodeVarName}->{GetDeserializationMethodName(property.Type, currentElement)}";
writer.StartBlock($"{(includeElse ? "} else " : string.Empty)}if ({serializationMethodName} !== null) {{");
if (serializationMethodName.Contains("getCollectionOfPrimitiveValues", StringComparison.Ordinal))
{
writer.WriteLine($"{ResultVarName}->{property.Setter!.Name.ToFirstCharacterLowerCase()}({ParseNodeVarName}->getStringValue());");
}
else
{
writer.WriteLine($"{ResultVarName}->{property.Setter!.Name.ToFirstCharacterLowerCase()}({serializationMethodName});");
}
writer.WriteLine($"{ResultVarName}->{property.Setter!.Name.ToFirstCharacterLowerCase()}({serializationMethodName});");
writer.DecreaseIndent();
if (!includeElse)
includeElse = true;
Expand Down

0 comments on commit a11a427

Please sign in to comment.