quicktype-core 20.0.20 → 20.0.22
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.
- package/dist/language/Php.js +21 -21
- package/package.json +1 -1
package/dist/language/Php.js
CHANGED
|
@@ -58,9 +58,9 @@ class PhpTargetLanguage extends TargetLanguage_1.TargetLanguage {
|
|
|
58
58
|
}
|
|
59
59
|
get stringTypeMapping() {
|
|
60
60
|
const mapping = new Map();
|
|
61
|
-
mapping.set("date", "date"); // TODO is not implemented yet
|
|
62
|
-
mapping.set("time", "time"); // TODO is not implemented yet
|
|
63
|
-
mapping.set("uuid", "uuid"); // TODO is not implemented yet
|
|
61
|
+
mapping.set("date", "date"); // TODO is not implemented yet
|
|
62
|
+
mapping.set("time", "time"); // TODO is not implemented yet
|
|
63
|
+
mapping.set("uuid", "uuid"); // TODO is not implemented yet
|
|
64
64
|
mapping.set("date-time", "date-time");
|
|
65
65
|
return mapping;
|
|
66
66
|
}
|
|
@@ -69,7 +69,7 @@ exports.PhpTargetLanguage = PhpTargetLanguage;
|
|
|
69
69
|
exports.stringEscape = (0, Strings_1.utf16ConcatMap)((0, Strings_1.escapeNonPrintableMapper)(Strings_1.isAscii, Strings_1.standardUnicodeHexEscape));
|
|
70
70
|
function isStartCharacter(codePoint) {
|
|
71
71
|
if (codePoint === 0x5f)
|
|
72
|
-
return true; // underscore
|
|
72
|
+
return true; // underscore
|
|
73
73
|
return (0, Strings_1.isAscii)(codePoint) && (0, Strings_1.isLetter)(codePoint);
|
|
74
74
|
}
|
|
75
75
|
function isPartCharacter(codePoint) {
|
|
@@ -156,7 +156,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
finishFile() {
|
|
159
|
-
// empty
|
|
159
|
+
// empty
|
|
160
160
|
}
|
|
161
161
|
emitFileHeader(fileName, _imports) {
|
|
162
162
|
this.startFile(fileName);
|
|
@@ -211,8 +211,8 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
213
|
phpConvertType(className, t) {
|
|
214
|
-
return (0, TypeUtils_1.matchType)(t, _anyType => "any", _nullType => "null", _boolType => "bool", _integerType => "int", _doubleType => "float", _stringType => "string", _arrayType => "array", _classType => "stdClass", _mapType => "stdClass", _enumType => "string", // TODO number this.nameForNamedType(enumType),
|
|
215
|
-
// TODO number this.nameForNamedType(enumType),
|
|
214
|
+
return (0, TypeUtils_1.matchType)(t, _anyType => "any", _nullType => "null", _boolType => "bool", _integerType => "int", _doubleType => "float", _stringType => "string", _arrayType => "array", _classType => "stdClass", _mapType => "stdClass", _enumType => "string", // TODO number this.nameForNamedType(enumType),
|
|
215
|
+
// TODO number this.nameForNamedType(enumType),
|
|
216
216
|
unionType => {
|
|
217
217
|
const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
218
218
|
if (nullable !== null) {
|
|
@@ -231,7 +231,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
231
231
|
this.emitLine(...lhs, "array_map(function ($value) {");
|
|
232
232
|
this.indent(() => {
|
|
233
233
|
this.phpToObjConvert(className, arrayType.items, ["return "], ["$value"]);
|
|
234
|
-
// this.emitLine("return $tmp;");
|
|
234
|
+
// this.emitLine("return $tmp;");
|
|
235
235
|
});
|
|
236
236
|
this.emitLine("}, ", ...args, ");");
|
|
237
237
|
}, _classType => this.emitLine(...lhs, ...args, "->to(); ", "/*class*/"), mapType => {
|
|
@@ -264,16 +264,16 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
264
264
|
}
|
|
265
265
|
transformDateTime(className, attrName, scopeAttrName) {
|
|
266
266
|
this.emitBlock(["if (!is_a(", scopeAttrName, ", 'DateTime'))"], () => this.emitLine("throw new Exception('Attribute Error:", className, "::", attrName, "');"));
|
|
267
|
-
// if (lhs !== undefined) {
|
|
268
|
-
// this.emitLine(lhs, "$tmp;");
|
|
269
|
-
// }
|
|
267
|
+
// if (lhs !== undefined) {
|
|
268
|
+
// this.emitLine(lhs, "$tmp;");
|
|
269
|
+
// }
|
|
270
270
|
}
|
|
271
271
|
phpFromObjConvert(className, t, lhs, args) {
|
|
272
272
|
return (0, TypeUtils_1.matchType)(t, _anyType => this.emitLine(...lhs, ...args, "; /*any*/"), _nullType => this.emitLine(...lhs, ...args, "; /*null*/"), _boolType => this.emitLine(...lhs, ...args, "; /*bool*/"), _integerType => this.emitLine(...lhs, ...args, "; /*int*/"), _doubleType => this.emitLine(...lhs, ...args, "; /*float*/"), _stringType => this.emitLine(...lhs, ...args, "; /*string*/"), arrayType => {
|
|
273
273
|
this.emitLine(...lhs, " array_map(function ($value) {");
|
|
274
274
|
this.indent(() => {
|
|
275
275
|
this.phpFromObjConvert(className, arrayType.items, ["return "], ["$value"]);
|
|
276
|
-
// this.emitLine("return $tmp;");
|
|
276
|
+
// this.emitLine("return $tmp;");
|
|
277
277
|
});
|
|
278
278
|
this.emitLine("}, ", ...args, ");");
|
|
279
279
|
}, classType => this.emitLine(...lhs, this.nameForNamedType(classType), "::from(", ...args, "); ", "/*class*/"), mapType => {
|
|
@@ -331,7 +331,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
331
331
|
if (transformedStringType.kind === "date-time") {
|
|
332
332
|
const x = _.pad("" + (1 + (idx % 31)), 2, "0");
|
|
333
333
|
this.emitLine(...lhs, "DateTime::createFromFormat(DateTimeInterface::ISO8601, '", `2020-12-${x}T12:${x}:${x}+00:00`, "')", suffix);
|
|
334
|
-
// this.emitLine("return sample();");
|
|
334
|
+
// this.emitLine("return sample();");
|
|
335
335
|
return;
|
|
336
336
|
}
|
|
337
337
|
throw Error('transformedStringType.kind === "unknown"');
|
|
@@ -381,7 +381,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
381
381
|
this.emitLine(" * ", desc);
|
|
382
382
|
this.emitLine(" *");
|
|
383
383
|
}
|
|
384
|
-
// this.emitLine(" * @param ", this.phpType(false, p.type, false, "", "|null"));
|
|
384
|
+
// this.emitLine(" * @param ", this.phpType(false, p.type, false, "", "|null"));
|
|
385
385
|
this.emitLine(" * @param ", this.phpConvertType(className, p.type), " $value");
|
|
386
386
|
this.emitLine(" * @throws Exception");
|
|
387
387
|
this.emitLine(" * @return ", this.phpType(false, p.type));
|
|
@@ -395,7 +395,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
395
395
|
this.phpType(false, p.type)
|
|
396
396
|
], () => {
|
|
397
397
|
this.phpFromObjConvert(className, p.type, ["return "], [`$value`]);
|
|
398
|
-
// this.emitLine("return $ret;");
|
|
398
|
+
// this.emitLine("return $ret;");
|
|
399
399
|
});
|
|
400
400
|
}
|
|
401
401
|
emitToMethod(names, p, className, name, desc) {
|
|
@@ -594,19 +594,19 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
594
594
|
this.finishFile();
|
|
595
595
|
}
|
|
596
596
|
emitUnionAttributes(_u, _unionName) {
|
|
597
|
-
// empty
|
|
597
|
+
// empty
|
|
598
598
|
}
|
|
599
599
|
emitUnionSerializer(_u, _unionName) {
|
|
600
|
-
// empty
|
|
600
|
+
// empty
|
|
601
601
|
}
|
|
602
602
|
emitUnionDefinition(_u, _unionName) {
|
|
603
603
|
throw Error("emitUnionDefinition not implemented");
|
|
604
604
|
}
|
|
605
605
|
emitEnumSerializationAttributes(_e) {
|
|
606
|
-
// Empty
|
|
606
|
+
// Empty
|
|
607
607
|
}
|
|
608
608
|
emitEnumDeserializationAttributes(_e) {
|
|
609
|
-
// Empty
|
|
609
|
+
// Empty
|
|
610
610
|
}
|
|
611
611
|
emitEnumDefinition(e, enumName) {
|
|
612
612
|
this.emitFileHeader(enumName, []);
|
|
@@ -647,7 +647,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
647
647
|
this.emitLine("switch ($obj->enum) {");
|
|
648
648
|
this.indent(() => {
|
|
649
649
|
this.forEachEnumCase(e, "none", (name, jsonName) => {
|
|
650
|
-
// Todo String or Number
|
|
650
|
+
// Todo String or Number
|
|
651
651
|
this.emitLine("case ", enumName, "::$", name, "->enum: return '", (0, exports.stringEscape)(jsonName), "';");
|
|
652
652
|
});
|
|
653
653
|
});
|
|
@@ -670,7 +670,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
670
670
|
this.emitLine("switch ($obj) {");
|
|
671
671
|
this.indent(() => {
|
|
672
672
|
this.forEachEnumCase(e, "none", (name, jsonName) => {
|
|
673
|
-
// Todo String or Enum
|
|
673
|
+
// Todo String or Enum
|
|
674
674
|
this.emitLine("case '", (0, exports.stringEscape)(jsonName), "': return ", enumName, "::$", name, ";");
|
|
675
675
|
});
|
|
676
676
|
});
|