diff --git a/modules/openapi-generator/src/main/resources/php-nextgen/model_generic.mustache b/modules/openapi-generator/src/main/resources/php-nextgen/model_generic.mustache index 0a199d959f74..109c5ea42933 100644 --- a/modules/openapi-generator/src/main/resources/php-nextgen/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/php-nextgen/model_generic.mustache @@ -446,7 +446,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}}{{/parentSchema}}{{^par } {{/minimum}} {{#pattern}} - if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}(!preg_match("{{{pattern}}}", ${{name}}))) { + if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}(!preg_match("{{{pattern}}}", ObjectSerializer::toString(${{name}})))) { throw new InvalidArgumentException("invalid value for \${{name}} when calling {{classname}}.{{operationId}}, must conform to the pattern {{{pattern}}}."); } {{/pattern}} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/FormatTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/FormatTest.php index 83f78ff27a84..1deda3bbc717 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/FormatTest.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/FormatTest.php @@ -716,7 +716,7 @@ public function setString(?string $string): static throw new InvalidArgumentException('non-nullable string cannot be null'); } - if ((!preg_match("/[a-z]/i", $string))) { + if ((!preg_match("/[a-z]/i", ObjectSerializer::toString($string)))) { throw new InvalidArgumentException("invalid value for \$string when calling FormatTest., must conform to the pattern /[a-z]/i."); } @@ -917,7 +917,7 @@ public function setPatternWithDigits(?string $pattern_with_digits): static throw new InvalidArgumentException('non-nullable pattern_with_digits cannot be null'); } - if ((!preg_match("/^\\d{10}$/", $pattern_with_digits))) { + if ((!preg_match("/^\\d{10}$/", ObjectSerializer::toString($pattern_with_digits)))) { throw new InvalidArgumentException("invalid value for \$pattern_with_digits when calling FormatTest., must conform to the pattern /^\\d{10}$/."); } @@ -949,7 +949,7 @@ public function setPatternWithDigitsAndDelimiter(?string $pattern_with_digits_an throw new InvalidArgumentException('non-nullable pattern_with_digits_and_delimiter cannot be null'); } - if ((!preg_match("/^image_\\d{1,3}$/i", $pattern_with_digits_and_delimiter))) { + if ((!preg_match("/^image_\\d{1,3}$/i", ObjectSerializer::toString($pattern_with_digits_and_delimiter)))) { throw new InvalidArgumentException("invalid value for \$pattern_with_digits_and_delimiter when calling FormatTest., must conform to the pattern /^image_\\d{1,3}$/i."); }