quicktype-core 23.3.9 → 23.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,5 +22,8 @@ function javaNameStyle(startWithUpper, upperUnderscore, original, acronymsStyle
22
22
  ? Strings_1.firstUpperWordStyle
23
23
  : Strings_1.allLowerWordStyle, upperUnderscore ? Strings_1.allUpperWordStyle : Strings_1.firstUpperWordStyle, upperUnderscore || startWithUpper
24
24
  ? Strings_1.allUpperWordStyle
25
- : Strings_1.allLowerWordStyle, acronymsStyle, upperUnderscore ? "_" : "", isStartCharacter);
25
+ : Strings_1.allLowerWordStyle,
26
+ // For UPPER_UNDERSCORE style (Java enum constants), always use allUpperWordStyle for acronyms
27
+ // to maintain consistency with the naming convention (e.g., XXX_SPA_XXX)
28
+ upperUnderscore ? Strings_1.allUpperWordStyle : acronymsStyle, upperUnderscore ? "_" : "", isStartCharacter);
26
29
  }
@@ -221,14 +221,11 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
221
221
  });
222
222
  this.emitLine("}, ", ...args, ");");
223
223
  }, (_classType) => this.emitLine(...lhs, ...args, "->to(); ", "/*class*/"), (mapType) => {
224
- this.emitBlock(["function to($my): stdClass"], () => {
225
- this.emitLine("$out = new stdClass();");
226
- this.emitBlock(["foreach ($my as $k => $v)"], () => {
227
- this.phpToObjConvert(className, mapType.values, ["$my->$k = "], ["$v"]);
228
- });
229
- this.emitLine("return $out;");
224
+ this.emitLine("$out = new stdClass();");
225
+ this.emitBlock(["foreach (", ...args, " as $k => $v)"], () => {
226
+ this.phpToObjConvert(className, mapType.values, ["$out->$k = "], ["$v"]);
230
227
  });
231
- this.emitLine("return to(", ...args, ");");
228
+ this.emitLine("return $out;");
232
229
  }, (enumType) => this.emitLine(...lhs, this.nameForNamedType(enumType), "::to(", ...args, "); ", "/*enum*/"), (unionType) => {
233
230
  const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
234
231
  if (nullable !== null) {
@@ -267,14 +264,11 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
267
264
  });
268
265
  this.emitLine("}, ", ...args, ");");
269
266
  }, (classType) => this.emitLine(...lhs, this.nameForNamedType(classType), "::from(", ...args, "); ", "/*class*/"), (mapType) => {
270
- this.emitBlock(["function from($my): stdClass"], () => {
271
- this.emitLine("$out = new stdClass();");
272
- this.emitBlock(["foreach ($my as $k => $v)"], () => {
273
- this.phpFromObjConvert(className, mapType.values, ["$out->$k = "], ["$v"]);
274
- });
275
- this.emitLine("return $out;");
267
+ this.emitLine("$out = new stdClass();");
268
+ this.emitBlock(["foreach (", ...args, " as $k => $v)"], () => {
269
+ this.phpFromObjConvert(className, mapType.values, ["$out->$k = "], ["$v"]);
276
270
  });
277
- this.emitLine("return from(", ...args, ");");
271
+ this.emitLine("return $out;");
278
272
  }, (enumType) => this.emitLine(...lhs, this.nameForNamedType(enumType), "::from(", ...args, "); ", "/*enum*/"), (unionType) => {
279
273
  const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
280
274
  if (nullable !== null) {
@@ -308,12 +302,9 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
308
302
  });
309
303
  this.emitLine("); /* ", "" + idx, ":", args, "*/");
310
304
  }, (classType) => this.emitLine(...lhs, this.nameForNamedType(classType), "::sample()", suffix, " /*", "" + idx, ":", args, "*/"), (mapType) => {
311
- this.emitBlock(["function sample(): stdClass"], () => {
312
- this.emitLine("$out = new stdClass();");
313
- this.phpSampleConvert(className, mapType.values, ["$out->{'", className, "'} = "], args, idx, ";");
314
- this.emitLine("return $out;");
315
- });
316
- this.emitLine("return sample();");
305
+ this.emitLine("$out = new stdClass();");
306
+ this.phpSampleConvert(className, mapType.values, ["$out->{'", className, "'} = "], args, idx, ";");
307
+ this.emitLine("return $out;");
317
308
  }, (enumType) => this.emitLine(...lhs, this.nameForNamedType(enumType), "::sample()", suffix, " /*enum*/"), (unionType) => {
318
309
  const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
319
310
  if (nullable !== null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quicktype-core",
3
- "version": "23.3.9",
3
+ "version": "23.3.11",
4
4
  "description": "The quicktype engine as a library",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",