[PHP] Skip length validation for DateTime model properties

Merged
22
5mo ago
+70-26

Fixes #24229.

What changed

  • Skips generated minLength / maxLength mb_strlen() checks for PHP model properties generated as \DateTime (date / date-time).
  • Keeps string length validation intact for normal string properties.
  • Applies the same template fix to php and php-nextgen.
  • Adds generator regression coverage for both PHP clients so a date-time field with length constraints does not emit mb_strlen(), while a regular string field still does.

Validation

  • Passed locally on Windows with Temurin JDK 17:
./mvnw -pl modules/openapi-generator -am \
  -Dtest=org.openapitools.codegen.php.PhpClientCodegenTest#testDateTimeLengthValidationIsNotGenerated,org.openapitools.codegen.php.PhpNextgenClientCodegenTest#testDateTimeLengthValidationIsNotGenerated \
  -Dsurefire.failIfNoSpecifiedTests=false test

Result: Tests run: 2, Failures: 0, Errors: 0, Skipped: 0.


Summary by cubic

Skip length validation for PHP \DateTime model properties (date/date-time) so we don’t call mb_strlen on dates while keeping string checks. Applies to php and php-nextgen; fixes #24229.

  • Bug Fixes
    • Wrapped maxLength/minLength in {{#isString}} ... {{/isString}} in both model_generic.mustache templates.
    • Added regression tests for php and php-nextgen (plus TestUtils import fix) and refreshed PHP samples to avoid drift.