[PHP] Allow strings with only whitespaces in enums (#12783)

This commit is contained in:
Thomas Hansen 2022-07-11 18:01:46 +02:00 committed by GitHub
parent cd48db43b4
commit 3e42a6eae0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -664,6 +664,10 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
return "EMPTY";
}
if(name.trim().length() == 0) {
return "SPACE_" + name.length();
}
// for symbol, e.g. $, #
if (getSymbolName(name) != null) {
return (getSymbolName(name)).toUpperCase(Locale.ROOT);
@ -739,6 +743,11 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
return input;
}
// If the string contains only "trim-able" characters, don't trim it
if(input.trim().length() == 0) {
return input;
}
// Trim the string to avoid leading and trailing spaces.
return super.escapeText(input).trim();
}