Skip to content

Commit

Permalink
Revert changes
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 3, 2024
1 parent a11a427 commit 994b96c
Showing 1 changed file with 4 additions and 32 deletions.
36 changes: 4 additions & 32 deletions src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,36 +482,12 @@ private string GetDeserializationMethodName(CodeTypeBase propType, CodeMethod me
var parseNodeMethod = string.Empty;
if (propType is CodeType currentType)
{
var collectionMethod = propType.IsArray ? "Array" : "Collection";
if (isCollection)
// parseNodeMethod = currentType.TypeDefinition switch
// {
// //CodeType codeType when codeType.TypeDefinition == null => $"getCollectionOfPrimitiveValues([{conventions.TranslateType(propType)}::class, '{CreateDiscriminatorMethodName}'])",
// CodeEnum enumType => $"getCollectionOfEnumValues({enumType.Name.ToFirstCharacterUpperCase()}::class)",
// //CodeType codeType when conventions.PrimitiveTypes.Contains(codeType.Name.ToLowerInvariant()) => $"getCollectionOfPrimitiveValues([{conventions.TranslateType(propType)}::class, '{CreateDiscriminatorMethodName}'])",
// _ => $"getCollectionOfPrimitiveValues([{conventions.TranslateType(propType)}::class, '{CreateDiscriminatorMethodName}'])"
// };
if (currentType.TypeDefinition is null)
{
//Set the parseNodeMethod to the appropriate method for the collection of primitive values
parseNodeMethod = $"getStringValue()";
}
// else if (conventions.PrimitiveTypes.Contains(currentType.TypeDefinition.Name.ToLowerInvariant()))
// {
// parseNodeMethod = currentType.TypeDefinition.Name.ToLowerInvariant();
// }
// else if (conventions.CustomTypes.Contains(currentType.TypeDefinition.Name.ToFirstCharacterUpperCase()))
// {
// parseNodeMethod = currentType.TypeDefinition.Name.ToLowerInvariant();
// }
else if (currentType.TypeDefinition is CodeEnum)
parseNodeMethod = currentType.TypeDefinition switch
{
parseNodeMethod = $"getCollectionOfEnumValues({currentType.TypeDefinition.Name.ToFirstCharacterUpperCase()}::class)";
}
else
{
parseNodeMethod = $"getCollectionOfObjectValues([{conventions.TranslateType(propType)}::class, '{CreateDiscriminatorMethodName}'])";
}
CodeEnum enumType => $"getCollectionOfEnumValues({enumType.Name.ToFirstCharacterUpperCase()}::class)",
_ => $"getCollectionOfObjectValues([{conventions.TranslateType(propType)}::class, '{CreateDiscriminatorMethodName}'])"
};
else if (currentType.TypeDefinition is CodeEnum)
parseNodeMethod = $"getEnumValue({propertyType.ToFirstCharacterUpperCase()}::class)";
}
Expand All @@ -525,9 +501,6 @@ private string GetDeserializationMethodName(CodeTypeBase propType, CodeMethod me
"decimal" or "double" => "getFloatValue()",
"streaminterface" => "getBinaryContent()",
"byte" => "getByteValue()",
// "string" => "getStringValue()",
// "date" => "getDateValue()",
// "datetime" => "getDateTimeValue()",
_ when conventions.PrimitiveTypes.Contains(lowerCaseType) => $"get{propertyType.ToFirstCharacterUpperCase()}Value()",
_ => $"getObjectValue([{propertyType.ToFirstCharacterUpperCase()}::class, '{CreateDiscriminatorMethodName}'])",
} : parseNodeMethod;
Expand Down Expand Up @@ -956,7 +929,6 @@ private void WriteFactoryMethodBodyForIntersectionModel(CodeMethod codeElement,
writer.CloseBlock(decreaseIndent: false);
}


private void WriteFactoryMethodBodyForUnionModelForDiscriminatedTypes(CodeMethod codeElement, CodeClass parentClass, LanguageWriter writer)
{
var includeElse = false;
Expand Down

0 comments on commit 994b96c

Please sign in to comment.