diff --git a/CHANGELOG.md b/CHANGELOG.md index 55b6590f54..71e6a1821e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,9 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added ### Changed - - Fixed Python error when a class inherits from a base class and implements an interface. [5637](https://github.com/microsoft/kiota/issues/5637) - Fix anyOf/oneOf generation in TypeScript. [5353](https://github.com/microsoft/kiota/issues/5353) +- Fixed invalid code in Php caused by "*/*/" in property description. [5635](https://github.com/microsoft/kiota/issues/5635) ## [1.20.0] - 2024-11-07 diff --git a/src/Kiota.Builder/Writers/Php/PhpConventionService.cs b/src/Kiota.Builder/Writers/Php/PhpConventionService.cs index 67cee78295..2f74723278 100644 --- a/src/Kiota.Builder/Writers/Php/PhpConventionService.cs +++ b/src/Kiota.Builder/Writers/Php/PhpConventionService.cs @@ -135,7 +135,7 @@ private string GetCollectionDocString(CodeParameter codeParameter) return codeParameter.Optional ? $"{doc}|null" : doc; } - internal static string RemoveInvalidDescriptionCharacters(string originalDescription) => originalDescription.Replace("\\", "/", StringComparison.OrdinalIgnoreCase); + internal static string RemoveInvalidDescriptionCharacters(string originalDescription) => originalDescription.Replace("\\", "/", StringComparison.OrdinalIgnoreCase).Replace("*/", "", StringComparison.OrdinalIgnoreCase); public override bool WriteShortDescription(IDocumentedElement element, LanguageWriter writer, string prefix = "", string suffix = "") { ArgumentNullException.ThrowIfNull(writer); diff --git a/tests/Kiota.Builder.Tests/Writers/Php/CodePropertyWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/Php/CodePropertyWriterTests.cs index a00225e813..4b96585405 100644 --- a/tests/Kiota.Builder.Tests/Writers/Php/CodePropertyWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/Php/CodePropertyWriterTests.cs @@ -246,4 +246,26 @@ public async Task WriteRequestOptionAsync() Assert.Contains("@var array|null $options", result); Assert.Contains("public ?array $options = null;", result); } + + [Fact] + public void WritePropertyWithDescription() + { + CodeProperty property = new CodeProperty + { + Name = "name", + Documentation = new() + { + DescriptionTemplate = "The name pattern that branches must match in order to deploy to the environment.Wildcard characters will not match `/`. For example, to match branches that begin with `release/` and contain an additional single slash, use `release/*/*`.For more information about pattern matching syntax, see the [Ruby File.fnmatch documentation](https://ruby-doc.org/core-2.5.1/File.html#method-c-fnmatch).", + }, + Type = new CodeType + { + Name = "string" + }, + Access = AccessModifier.Private + }; + parentClass.AddProperty(property); + propertyWriter.WriteCodeElement(property, languageWriter); + var result = stringWriter.ToString(); + Assert.DoesNotContain("/*/*", result); + } }