From c0e2014465a9493deceba66ff9dc0ae46310bcc7 Mon Sep 17 00:00:00 2001 From: silaskenneth Date: Tue, 3 Oct 2023 17:49:46 +0300 Subject: [PATCH 1/3] Fix casing and ignore errors with hashmap keys. --- it/php/phpstan.neon | 2 +- src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/it/php/phpstan.neon b/it/php/phpstan.neon index 2078f3f5bc..11ffe2a09e 100644 --- a/it/php/phpstan.neon +++ b/it/php/phpstan.neon @@ -7,4 +7,4 @@ parameters: - src ignoreErrors: - '#Parameter [\w\W]+ \$errorMappings of method [\w\\]+RequestAdapter::send[\w]+\(\) expects [\w\W\s]+ given\.#' - - '#getFieldDeserializers\(\) should return array\ but returns array\{[\d]\: Closure\(Microsoft\\Kiota\\Abstractions\\Serialization\\ParseNode\)\: void.+#' + - '#getFieldDeserializers\(\) should return array\ but returns array\{[\d]+\: Closure\(Microsoft\\Kiota\\Abstractions\\Serialization\\ParseNode\)\: void.+#' diff --git a/src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs index b78583bc2a..7c15d5e6ad 100644 --- a/src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs @@ -268,7 +268,7 @@ private string GetDocCommentReturnType(CodeMethod codeMethod) { return codeMethod.Kind switch { - CodeMethodKind.Deserializer => "array", + CodeMethodKind.Deserializer => "array", CodeMethodKind.Getter when codeMethod.AccessedProperty?.IsOfKind(CodePropertyKind.AdditionalData) ?? false => "array", CodeMethodKind.Getter when codeMethod.AccessedProperty?.Type.IsCollection ?? false => $"array<{conventions.TranslateType(codeMethod.AccessedProperty.Type)}>", _ => conventions.GetTypeString(codeMethod.ReturnType, codeMethod) @@ -719,7 +719,7 @@ private void WriteRequestExecutorBody(CodeMethod codeElement, CodeClass parentCl writer.IncreaseIndent(2); errorMappings.ToList().ForEach(errorMapping => { - writer.WriteLine($"'{errorMapping.Key}' => [{errorMapping.Value.Name}::class, '{CreateDiscriminatorMethodName}'],"); + writer.WriteLine($"'{errorMapping.Key}' => [{errorMapping.Value.Name.ToFirstCharacterUpperCase()}::class, '{CreateDiscriminatorMethodName}'],"); }); writer.DecreaseIndent(); writer.WriteLine("];"); From 02529f27d5e996286c261be6f79ab7487ab097c0 Mon Sep 17 00:00:00 2001 From: silaskenneth Date: Tue, 3 Oct 2023 17:54:20 +0300 Subject: [PATCH 2/3] Add changelog entry. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ab38dd31b..0686ad3f05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added a new switch to exclude all assets generated only for backward compatibility. [#2952](https://github.com/microsoft/kiota/issues/2952) ### Changed - +- Fix class name casings when reference in the errorMappings in PHP. - Fixed imports for enum type properties with default values in Python. [#3367](https://github.com/microsoft/kiota/issues/3367) - Updated constructor for request builders in Python to set passed path parameters. [#3352](https://github.com/microsoft/kiota/issues/3352) - Fixed inherited type definition generation where some cases would not generate properly. [#2745](https://github.com/microsoft/kiota/issues/2745) From 34e5fd14b40ea4e2b2790b199fb2a06894c8b692 Mon Sep 17 00:00:00 2001 From: silaskenneth Date: Tue, 3 Oct 2023 17:57:20 +0300 Subject: [PATCH 3/3] Remove int from key types as an option. --- src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs index 7c15d5e6ad..515925f4ac 100644 --- a/src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs @@ -268,7 +268,7 @@ private string GetDocCommentReturnType(CodeMethod codeMethod) { return codeMethod.Kind switch { - CodeMethodKind.Deserializer => "array", + CodeMethodKind.Deserializer => "array", CodeMethodKind.Getter when codeMethod.AccessedProperty?.IsOfKind(CodePropertyKind.AdditionalData) ?? false => "array", CodeMethodKind.Getter when codeMethod.AccessedProperty?.Type.IsCollection ?? false => $"array<{conventions.TranslateType(codeMethod.AccessedProperty.Type)}>", _ => conventions.GetTypeString(codeMethod.ReturnType, codeMethod)