quicktype 18.0.6 → 19.0.4

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.
Files changed (174) hide show
  1. package/README.md +1 -1
  2. package/dist/{cli/CompressedJSONFromStream.d.ts → CompressedJSONFromStream.d.ts} +1 -1
  3. package/dist/{cli/CompressedJSONFromStream.js → CompressedJSONFromStream.js} +2 -2
  4. package/dist/{cli/GraphQLIntrospection.d.ts → GraphQLIntrospection.d.ts} +0 -0
  5. package/dist/{cli/GraphQLIntrospection.js → GraphQLIntrospection.js} +1 -1
  6. package/dist/{cli/TypeSource.d.ts → TypeSource.d.ts} +2 -2
  7. package/dist/{cli/TypeSource.js → TypeSource.js} +0 -0
  8. package/dist/{cli/URLGrammar.d.ts → URLGrammar.d.ts} +0 -0
  9. package/dist/{cli/URLGrammar.js → URLGrammar.js} +1 -1
  10. package/dist/{cli/index.d.ts → index.d.ts} +1 -1
  11. package/dist/{cli/index.js → index.js} +4 -5
  12. package/package.json +61 -77
  13. package/dist/quicktype-core/Annotation.d.ts +0 -8
  14. package/dist/quicktype-core/Annotation.js +0 -16
  15. package/dist/quicktype-core/ConvenienceRenderer.d.ts +0 -138
  16. package/dist/quicktype-core/ConvenienceRenderer.js +0 -668
  17. package/dist/quicktype-core/DateTime.d.ts +0 -10
  18. package/dist/quicktype-core/DateTime.js +0 -57
  19. package/dist/quicktype-core/DeclarationIR.d.ts +0 -14
  20. package/dist/quicktype-core/DeclarationIR.js +0 -167
  21. package/dist/quicktype-core/EncodedMarkovChain.d.ts +0 -1
  22. package/dist/quicktype-core/EncodedMarkovChain.js +0 -4
  23. package/dist/quicktype-core/GatherNames.d.ts +0 -2
  24. package/dist/quicktype-core/GatherNames.js +0 -333
  25. package/dist/quicktype-core/Graph.d.ts +0 -12
  26. package/dist/quicktype-core/Graph.js +0 -220
  27. package/dist/quicktype-core/GraphRewriting.d.ts +0 -87
  28. package/dist/quicktype-core/GraphRewriting.js +0 -421
  29. package/dist/quicktype-core/MakeTransformations.d.ts +0 -4
  30. package/dist/quicktype-core/MakeTransformations.js +0 -193
  31. package/dist/quicktype-core/MarkovChain.d.ts +0 -15
  32. package/dist/quicktype-core/MarkovChain.js +0 -154
  33. package/dist/quicktype-core/Messages.d.ts +0 -294
  34. package/dist/quicktype-core/Messages.js +0 -105
  35. package/dist/quicktype-core/Naming.d.ts +0 -64
  36. package/dist/quicktype-core/Naming.js +0 -356
  37. package/dist/quicktype-core/Renderer.d.ts +0 -50
  38. package/dist/quicktype-core/Renderer.js +0 -274
  39. package/dist/quicktype-core/RendererOptions.d.ts +0 -71
  40. package/dist/quicktype-core/RendererOptions.js +0 -141
  41. package/dist/quicktype-core/Run.d.ts +0 -174
  42. package/dist/quicktype-core/Run.js +0 -393
  43. package/dist/quicktype-core/Source.d.ts +0 -65
  44. package/dist/quicktype-core/Source.js +0 -204
  45. package/dist/quicktype-core/TargetLanguage.d.ts +0 -34
  46. package/dist/quicktype-core/TargetLanguage.js +0 -66
  47. package/dist/quicktype-core/Transformers.d.ts +0 -209
  48. package/dist/quicktype-core/Transformers.js +0 -836
  49. package/dist/quicktype-core/Type.d.ts +0 -206
  50. package/dist/quicktype-core/Type.js +0 -716
  51. package/dist/quicktype-core/TypeBuilder.d.ts +0 -61
  52. package/dist/quicktype-core/TypeBuilder.js +0 -324
  53. package/dist/quicktype-core/TypeGraph.d.ts +0 -75
  54. package/dist/quicktype-core/TypeGraph.js +0 -420
  55. package/dist/quicktype-core/TypeUtils.d.ts +0 -33
  56. package/dist/quicktype-core/TypeUtils.js +0 -230
  57. package/dist/quicktype-core/UnifyClasses.d.ts +0 -16
  58. package/dist/quicktype-core/UnifyClasses.js +0 -159
  59. package/dist/quicktype-core/UnionBuilder.d.ts +0 -49
  60. package/dist/quicktype-core/UnionBuilder.js +0 -282
  61. package/dist/quicktype-core/attributes/AccessorNames.d.ts +0 -18
  62. package/dist/quicktype-core/attributes/AccessorNames.js +0 -182
  63. package/dist/quicktype-core/attributes/Constraints.d.ts +0 -38
  64. package/dist/quicktype-core/attributes/Constraints.js +0 -172
  65. package/dist/quicktype-core/attributes/Description.d.ts +0 -9
  66. package/dist/quicktype-core/attributes/Description.js +0 -97
  67. package/dist/quicktype-core/attributes/EnumValues.d.ts +0 -8
  68. package/dist/quicktype-core/attributes/EnumValues.js +0 -31
  69. package/dist/quicktype-core/attributes/StringTypes.d.ts +0 -28
  70. package/dist/quicktype-core/attributes/StringTypes.js +0 -189
  71. package/dist/quicktype-core/attributes/TypeAttributes.d.ts +0 -34
  72. package/dist/quicktype-core/attributes/TypeAttributes.js +0 -119
  73. package/dist/quicktype-core/attributes/TypeNames.d.ts +0 -46
  74. package/dist/quicktype-core/attributes/TypeNames.js +0 -274
  75. package/dist/quicktype-core/attributes/URIAttributes.d.ts +0 -8
  76. package/dist/quicktype-core/attributes/URIAttributes.js +0 -85
  77. package/dist/quicktype-core/index.d.ts +0 -48
  78. package/dist/quicktype-core/index.js +0 -180
  79. package/dist/quicktype-core/input/CompressedJSON.d.ts +0 -69
  80. package/dist/quicktype-core/input/CompressedJSON.js +0 -276
  81. package/dist/quicktype-core/input/FetchingJSONSchemaStore.d.ts +0 -6
  82. package/dist/quicktype-core/input/FetchingJSONSchemaStore.js +0 -18
  83. package/dist/quicktype-core/input/Inference.d.ts +0 -22
  84. package/dist/quicktype-core/input/Inference.js +0 -240
  85. package/dist/quicktype-core/input/Inputs.d.ts +0 -48
  86. package/dist/quicktype-core/input/Inputs.js +0 -145
  87. package/dist/quicktype-core/input/JSONSchemaInput.d.ts +0 -91
  88. package/dist/quicktype-core/input/JSONSchemaInput.js +0 -1041
  89. package/dist/quicktype-core/input/JSONSchemaStore.d.ts +0 -8
  90. package/dist/quicktype-core/input/JSONSchemaStore.js +0 -36
  91. package/dist/quicktype-core/input/PostmanCollection.d.ts +0 -5
  92. package/dist/quicktype-core/input/PostmanCollection.js +0 -60
  93. package/dist/quicktype-core/input/io/NodeIO.d.ts +0 -3
  94. package/dist/quicktype-core/input/io/NodeIO.js +0 -87
  95. package/dist/quicktype-core/input/io/get-stream/buffer-stream.d.ts +0 -2
  96. package/dist/quicktype-core/input/io/get-stream/buffer-stream.js +0 -45
  97. package/dist/quicktype-core/input/io/get-stream/index.d.ts +0 -9
  98. package/dist/quicktype-core/input/io/get-stream/index.js +0 -52
  99. package/dist/quicktype-core/language/All.d.ts +0 -3
  100. package/dist/quicktype-core/language/All.js +0 -57
  101. package/dist/quicktype-core/language/CPlusPlus.d.ts +0 -241
  102. package/dist/quicktype-core/language/CPlusPlus.js +0 -1847
  103. package/dist/quicktype-core/language/CSharp.d.ts +0 -201
  104. package/dist/quicktype-core/language/CSharp.js +0 -1850
  105. package/dist/quicktype-core/language/Crystal.d.ts +0 -37
  106. package/dist/quicktype-core/language/Crystal.js +0 -337
  107. package/dist/quicktype-core/language/Dart.d.ts +0 -66
  108. package/dist/quicktype-core/language/Dart.js +0 -576
  109. package/dist/quicktype-core/language/Elm.d.ts +0 -58
  110. package/dist/quicktype-core/language/Elm.js +0 -522
  111. package/dist/quicktype-core/language/Golang.d.ts +0 -51
  112. package/dist/quicktype-core/language/Golang.js +0 -460
  113. package/dist/quicktype-core/language/Haskell.d.ts +0 -56
  114. package/dist/quicktype-core/language/Haskell.js +0 -411
  115. package/dist/quicktype-core/language/JSONSchema.d.ts +0 -31
  116. package/dist/quicktype-core/language/JSONSchema.js +0 -169
  117. package/dist/quicktype-core/language/Java.d.ts +0 -125
  118. package/dist/quicktype-core/language/Java.js +0 -1081
  119. package/dist/quicktype-core/language/JavaScript.d.ts +0 -68
  120. package/dist/quicktype-core/language/JavaScript.js +0 -435
  121. package/dist/quicktype-core/language/JavaScriptPropTypes.d.ts +0 -40
  122. package/dist/quicktype-core/language/JavaScriptPropTypes.js +0 -213
  123. package/dist/quicktype-core/language/JavaScriptUnicodeMaps.d.ts +0 -2
  124. package/dist/quicktype-core/language/JavaScriptUnicodeMaps.js +0 -134
  125. package/dist/quicktype-core/language/Kotlin.d.ts +0 -109
  126. package/dist/quicktype-core/language/Kotlin.js +0 -832
  127. package/dist/quicktype-core/language/Objective-C.d.ts +0 -79
  128. package/dist/quicktype-core/language/Objective-C.js +0 -777
  129. package/dist/quicktype-core/language/Php.d.ts +0 -80
  130. package/dist/quicktype-core/language/Php.js +0 -702
  131. package/dist/quicktype-core/language/Pike.d.ts +0 -37
  132. package/dist/quicktype-core/language/Pike.js +0 -276
  133. package/dist/quicktype-core/language/Python.d.ts +0 -107
  134. package/dist/quicktype-core/language/Python.js +0 -969
  135. package/dist/quicktype-core/language/Rust.d.ts +0 -56
  136. package/dist/quicktype-core/language/Rust.js +0 -309
  137. package/dist/quicktype-core/language/Swift.d.ts +0 -96
  138. package/dist/quicktype-core/language/Swift.js +0 -1211
  139. package/dist/quicktype-core/language/TypeScriptFlow.d.ts +0 -77
  140. package/dist/quicktype-core/language/TypeScriptFlow.js +0 -286
  141. package/dist/quicktype-core/language/ruby/index.d.ts +0 -52
  142. package/dist/quicktype-core/language/ruby/index.js +0 -557
  143. package/dist/quicktype-core/language/ruby/keywords.d.ts +0 -3
  144. package/dist/quicktype-core/language/ruby/keywords.js +0 -358
  145. package/dist/quicktype-core/rewrites/CombineClasses.d.ts +0 -3
  146. package/dist/quicktype-core/rewrites/CombineClasses.js +0 -125
  147. package/dist/quicktype-core/rewrites/ExpandStrings.d.ts +0 -4
  148. package/dist/quicktype-core/rewrites/ExpandStrings.js +0 -143
  149. package/dist/quicktype-core/rewrites/FlattenStrings.d.ts +0 -3
  150. package/dist/quicktype-core/rewrites/FlattenStrings.js +0 -45
  151. package/dist/quicktype-core/rewrites/FlattenUnions.d.ts +0 -3
  152. package/dist/quicktype-core/rewrites/FlattenUnions.js +0 -47
  153. package/dist/quicktype-core/rewrites/InferMaps.d.ts +0 -3
  154. package/dist/quicktype-core/rewrites/InferMaps.js +0 -117
  155. package/dist/quicktype-core/rewrites/ReplaceObjectType.d.ts +0 -3
  156. package/dist/quicktype-core/rewrites/ReplaceObjectType.js +0 -60
  157. package/dist/quicktype-core/rewrites/ResolveIntersections.d.ts +0 -3
  158. package/dist/quicktype-core/rewrites/ResolveIntersections.js +0 -244
  159. package/dist/quicktype-core/support/Acronyms.d.ts +0 -10
  160. package/dist/quicktype-core/support/Acronyms.js +0 -1128
  161. package/dist/quicktype-core/support/Chance.d.ts +0 -38
  162. package/dist/quicktype-core/support/Chance.js +0 -2146
  163. package/dist/quicktype-core/support/Converters.d.ts +0 -6
  164. package/dist/quicktype-core/support/Converters.js +0 -16
  165. package/dist/quicktype-core/support/Strings.d.ts +0 -44
  166. package/dist/quicktype-core/support/Strings.js +0 -525
  167. package/dist/quicktype-core/support/Support.d.ts +0 -29
  168. package/dist/quicktype-core/support/Support.js +0 -162
  169. package/dist/quicktype-graphql-input/GraphQLSchema.d.ts +0 -645
  170. package/dist/quicktype-graphql-input/GraphQLSchema.js +0 -39
  171. package/dist/quicktype-graphql-input/index.d.ts +0 -17
  172. package/dist/quicktype-graphql-input/index.js +0 -407
  173. package/dist/quicktype-typescript-input/index.d.ts +0 -2
  174. package/dist/quicktype-typescript-input/index.js +0 -98
@@ -1,702 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.PhpRenderer = exports.phpNameStyle = exports.stringEscape = exports.PhpTargetLanguage = exports.phpOptions = void 0;
27
- const Annotation_1 = require("../Annotation");
28
- const ConvenienceRenderer_1 = require("../ConvenienceRenderer");
29
- const Naming_1 = require("../Naming");
30
- const RendererOptions_1 = require("../RendererOptions");
31
- const Source_1 = require("../Source");
32
- const Acronyms_1 = require("../support/Acronyms");
33
- const Strings_1 = require("../support/Strings");
34
- const Support_1 = require("../support/Support");
35
- const TargetLanguage_1 = require("../TargetLanguage");
36
- const TypeUtils_1 = require("../TypeUtils");
37
- const _ = __importStar(require("lodash"));
38
- exports.phpOptions = {
39
- withGet: new RendererOptions_1.BooleanOption("with-get", "Create Getter", true),
40
- fastGet: new RendererOptions_1.BooleanOption("fast-get", "getter without validation", false),
41
- withSet: new RendererOptions_1.BooleanOption("with-set", "Create Setter", false),
42
- withClosing: new RendererOptions_1.BooleanOption("with-closing", "PHP Closing Tag", false),
43
- acronymStyle: (0, Acronyms_1.acronymOption)(Acronyms_1.AcronymStyleOptions.Pascal)
44
- };
45
- class PhpTargetLanguage extends TargetLanguage_1.TargetLanguage {
46
- constructor() {
47
- super("Php", ["php"], "php");
48
- }
49
- getOptions() {
50
- return _.values(exports.phpOptions);
51
- }
52
- get supportsUnionsWithBothNumberTypes() {
53
- return true;
54
- }
55
- makeRenderer(renderContext, untypedOptionValues) {
56
- const options = (0, RendererOptions_1.getOptionValues)(exports.phpOptions, untypedOptionValues);
57
- return new PhpRenderer(this, renderContext, options);
58
- }
59
- get stringTypeMapping() {
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
64
- mapping.set("date-time", "date-time");
65
- return mapping;
66
- }
67
- }
68
- exports.PhpTargetLanguage = PhpTargetLanguage;
69
- exports.stringEscape = (0, Strings_1.utf16ConcatMap)((0, Strings_1.escapeNonPrintableMapper)(Strings_1.isAscii, Strings_1.standardUnicodeHexEscape));
70
- function isStartCharacter(codePoint) {
71
- if (codePoint === 0x5f)
72
- return true; // underscore
73
- return (0, Strings_1.isAscii)(codePoint) && (0, Strings_1.isLetter)(codePoint);
74
- }
75
- function isPartCharacter(codePoint) {
76
- return isStartCharacter(codePoint) || ((0, Strings_1.isAscii)(codePoint) && (0, Strings_1.isDigit)(codePoint));
77
- }
78
- const legalizeName = (0, Strings_1.utf16LegalizeCharacters)(isPartCharacter);
79
- function phpNameStyle(startWithUpper, upperUnderscore, original, acronymsStyle = Strings_1.allUpperWordStyle) {
80
- const words = (0, Strings_1.splitIntoWords)(original);
81
- return (0, Strings_1.combineWords)(words, legalizeName, upperUnderscore ? Strings_1.allUpperWordStyle : startWithUpper ? Strings_1.firstUpperWordStyle : Strings_1.allLowerWordStyle, upperUnderscore ? Strings_1.allUpperWordStyle : Strings_1.firstUpperWordStyle, upperUnderscore || startWithUpper ? Strings_1.allUpperWordStyle : Strings_1.allLowerWordStyle, acronymsStyle, upperUnderscore ? "_" : "", isStartCharacter);
82
- }
83
- exports.phpNameStyle = phpNameStyle;
84
- class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
85
- _options;
86
- _gettersAndSettersForPropertyName = new Map();
87
- _haveEmittedLeadingComments = false;
88
- _converterClassname = "Converter";
89
- _converterKeywords = [];
90
- constructor(targetLanguage, renderContext, _options) {
91
- super(targetLanguage, renderContext);
92
- this._options = _options;
93
- }
94
- forbiddenForObjectProperties(_c, _className) {
95
- return { names: [], includeGlobalForbidden: true };
96
- }
97
- makeNamedTypeNamer() {
98
- return this.getNameStyling("typeNamingFunction");
99
- }
100
- namerForObjectProperty() {
101
- return this.getNameStyling("propertyNamingFunction");
102
- }
103
- makeUnionMemberNamer() {
104
- return this.getNameStyling("propertyNamingFunction");
105
- }
106
- makeEnumCaseNamer() {
107
- return this.getNameStyling("enumCaseNamingFunction");
108
- }
109
- unionNeedsName(u) {
110
- return (0, TypeUtils_1.nullableFromUnion)(u) === null;
111
- }
112
- namedTypeToNameForTopLevel(type) {
113
- return (0, TypeUtils_1.directlyReachableSingleNamedType)(type);
114
- }
115
- makeNamesForPropertyGetterAndSetter(_c, _className, _p, _jsonName, name) {
116
- const getterName = new Naming_1.DependencyName(this.getNameStyling("propertyNamingFunction"), name.order, lookup => `get_${lookup(name)}`);
117
- const setterName = new Naming_1.DependencyName(this.getNameStyling("propertyNamingFunction"), name.order, lookup => `set_${lookup(name)}`);
118
- const validateName = new Naming_1.DependencyName(this.getNameStyling("propertyNamingFunction"), name.order, lookup => `validate_${lookup(name)}`);
119
- const fromName = new Naming_1.DependencyName(this.getNameStyling("propertyNamingFunction"), name.order, lookup => `from_${lookup(name)}`);
120
- const toName = new Naming_1.DependencyName(this.getNameStyling("propertyNamingFunction"), name.order, lookup => `to_${lookup(name)}`);
121
- const sampleName = new Naming_1.DependencyName(this.getNameStyling("propertyNamingFunction"), name.order, lookup => `sample_${lookup(name)}`);
122
- return {
123
- getter: getterName,
124
- setter: setterName,
125
- validate: validateName,
126
- from: fromName,
127
- to: toName,
128
- sample: sampleName
129
- };
130
- }
131
- makePropertyDependencyNames(c, className, p, jsonName, name) {
132
- const getterAndSetterNames = this.makeNamesForPropertyGetterAndSetter(c, className, p, jsonName, name);
133
- this._gettersAndSettersForPropertyName.set(name, getterAndSetterNames);
134
- return [
135
- getterAndSetterNames.getter,
136
- getterAndSetterNames.setter,
137
- getterAndSetterNames.validate,
138
- getterAndSetterNames.to,
139
- getterAndSetterNames.from,
140
- getterAndSetterNames.sample
141
- ];
142
- }
143
- getNameStyling(convention) {
144
- const styling = {
145
- typeNamingFunction: (0, Naming_1.funPrefixNamer)("types", n => phpNameStyle(true, false, n, (0, Acronyms_1.acronymStyle)(this._options.acronymStyle))),
146
- propertyNamingFunction: (0, Naming_1.funPrefixNamer)("properties", n => phpNameStyle(false, false, n, (0, Acronyms_1.acronymStyle)(this._options.acronymStyle))),
147
- enumCaseNamingFunction: (0, Naming_1.funPrefixNamer)("enum-cases", n => phpNameStyle(true, true, n, (0, Acronyms_1.acronymStyle)(this._options.acronymStyle)))
148
- };
149
- return styling[convention];
150
- }
151
- startFile(_basename) {
152
- this.ensureBlankLine();
153
- if (!this._haveEmittedLeadingComments && this.leadingComments !== undefined) {
154
- this.emitCommentLines(this.leadingComments);
155
- this.ensureBlankLine();
156
- this._haveEmittedLeadingComments = true;
157
- }
158
- }
159
- finishFile() {
160
- // empty
161
- }
162
- emitFileHeader(fileName, _imports) {
163
- this.startFile(fileName);
164
- this.emitLine("// This is a autogenerated file:", fileName);
165
- this.ensureBlankLine();
166
- }
167
- emitDescriptionBlock(lines) {
168
- this.emitCommentLines(lines, " * ", "/**", " */");
169
- }
170
- emitBlock(line, f) {
171
- this.emitLine(line, " {");
172
- this.indent(f);
173
- this.emitLine("}");
174
- }
175
- phpType(_reference, t, isOptional = false, prefix = "?", suffix = "") {
176
- function optionalize(s) {
177
- return [isOptional ? prefix : "", s, isOptional ? suffix : ""];
178
- }
179
- return (0, TypeUtils_1.matchType)(t, _anyType => (0, Source_1.maybeAnnotated)(isOptional, Annotation_1.anyTypeIssueAnnotation, "Object"), _nullType => (0, Source_1.maybeAnnotated)(isOptional, Annotation_1.nullTypeIssueAnnotation, "Object"), _boolType => optionalize("bool"), _integerType => optionalize("int"), _doubleType => optionalize("float"), _stringType => optionalize("string"), _arrayType => optionalize("array"), classType => optionalize(this.nameForNamedType(classType)), _mapType => optionalize("stdClass"), enumType => optionalize(this.nameForNamedType(enumType)), unionType => {
180
- const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
181
- if (nullable !== null)
182
- return this.phpType(true, nullable, true, prefix, suffix);
183
- return this.nameForNamedType(unionType);
184
- }, transformedStringType => {
185
- if (transformedStringType.kind === "time") {
186
- throw Error('transformedStringType.kind === "time"');
187
- }
188
- if (transformedStringType.kind === "date") {
189
- throw Error('transformedStringType.kind === "date"');
190
- }
191
- if (transformedStringType.kind === "date-time") {
192
- return "DateTime";
193
- }
194
- if (transformedStringType.kind === "uuid") {
195
- throw Error('transformedStringType.kind === "uuid"');
196
- }
197
- return "string";
198
- });
199
- }
200
- phpDocConvertType(className, t) {
201
- return (0, TypeUtils_1.matchType)(t, _anyType => "any", _nullType => "null", _boolType => "bool", _integerType => "int", _doubleType => "float", _stringType => "string", arrayType => [this.phpDocConvertType(className, arrayType.items), "[]"], _classType => _classType.getCombinedName(), _mapType => "stdClass", enumType => this.nameForNamedType(enumType), unionType => {
202
- const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
203
- if (nullable !== null) {
204
- return [this.phpDocConvertType(className, nullable), "|null"];
205
- }
206
- throw Error("union are not supported");
207
- }, transformedStringType => {
208
- if (transformedStringType.kind === "date-time") {
209
- return "DateTime";
210
- }
211
- throw Error('transformedStringType.kind === "unknown"');
212
- });
213
- }
214
- phpConvertType(className, t) {
215
- 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),
216
- // TODO number this.nameForNamedType(enumType),
217
- unionType => {
218
- const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
219
- if (nullable !== null) {
220
- return ["?", this.phpConvertType(className, nullable)];
221
- }
222
- throw Error("union are not supported");
223
- }, transformedStringType => {
224
- if (transformedStringType.kind === "date-time") {
225
- return "string";
226
- }
227
- throw Error('transformedStringType.kind === "unknown"');
228
- });
229
- }
230
- phpToObjConvert(className, t, lhs, args) {
231
- 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 => {
232
- this.emitLine(...lhs, "array_map(function ($value) {");
233
- this.indent(() => {
234
- this.phpToObjConvert(className, arrayType.items, ["return "], ["$value"]);
235
- // this.emitLine("return $tmp;");
236
- });
237
- this.emitLine("}, ", ...args, ");");
238
- }, _classType => this.emitLine(...lhs, ...args, "->to(); ", "/*class*/"), mapType => {
239
- this.emitBlock(["function to($my): stdClass"], () => {
240
- this.emitLine("$out = new stdClass();");
241
- this.emitBlock(["foreach ($my as $k => $v)"], () => {
242
- this.phpToObjConvert(className, mapType.values, ["$my->$k = "], ["$v"]);
243
- });
244
- this.emitLine("return $out;");
245
- });
246
- this.emitLine("return to(", ...args, ");");
247
- }, enumType => this.emitLine(...lhs, this.nameForNamedType(enumType), "::to(", ...args, "); ", "/*enum*/"), unionType => {
248
- const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
249
- if (nullable !== null) {
250
- this.emitLine("if (!is_null(", ...args, ")) {");
251
- this.indent(() => this.phpToObjConvert(className, nullable, lhs, args));
252
- this.emitLine("} else {");
253
- this.indent(() => this.emitLine(...lhs, " null;"));
254
- this.emitLine("}");
255
- return;
256
- }
257
- throw Error("union are not supported");
258
- }, transformedStringType => {
259
- if (transformedStringType.kind === "date-time") {
260
- this.emitLine(...lhs, ...args, "->format(DateTimeInterface::ISO8601);");
261
- return;
262
- }
263
- throw Error('transformedStringType.kind === "unknown"');
264
- });
265
- }
266
- transformDateTime(className, attrName, scopeAttrName) {
267
- this.emitBlock(["if (!is_a(", scopeAttrName, ", 'DateTime'))"], () => this.emitLine("throw new Exception('Attribute Error:", className, "::", attrName, "');"));
268
- // if (lhs !== undefined) {
269
- // this.emitLine(lhs, "$tmp;");
270
- // }
271
- }
272
- phpFromObjConvert(className, t, lhs, args) {
273
- 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 => {
274
- this.emitLine(...lhs, " array_map(function ($value) {");
275
- this.indent(() => {
276
- this.phpFromObjConvert(className, arrayType.items, ["return "], ["$value"]);
277
- // this.emitLine("return $tmp;");
278
- });
279
- this.emitLine("}, ", ...args, ");");
280
- }, classType => this.emitLine(...lhs, this.nameForNamedType(classType), "::from(", ...args, "); ", "/*class*/"), mapType => {
281
- this.emitBlock(["function from($my): stdClass"], () => {
282
- this.emitLine("$out = new stdClass();");
283
- this.emitBlock(["foreach ($my as $k => $v)"], () => {
284
- this.phpFromObjConvert(className, mapType.values, ["$out->$k = "], ["$v"]);
285
- });
286
- this.emitLine("return $out;");
287
- });
288
- this.emitLine("return from(", ...args, ");");
289
- }, enumType => this.emitLine(...lhs, this.nameForNamedType(enumType), "::from(", ...args, "); ", "/*enum*/"), unionType => {
290
- const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
291
- if (nullable !== null) {
292
- this.emitLine("if (!is_null(", ...args, ")) {");
293
- this.indent(() => this.phpFromObjConvert(className, nullable, lhs, args));
294
- this.emitLine("} else {");
295
- this.indent(() => this.emitLine("return null;"));
296
- this.emitLine("}");
297
- return;
298
- }
299
- throw Error("union are not supported");
300
- }, transformedStringType => {
301
- if (transformedStringType.kind === "date-time") {
302
- this.emitLine("$tmp = ", "DateTime::createFromFormat(DateTimeInterface::ISO8601, ", args, ");");
303
- this.transformDateTime(className, "", ["$tmp"]);
304
- this.emitLine("return $tmp;");
305
- return;
306
- }
307
- throw Error('transformedStringType.kind === "unknown"');
308
- });
309
- }
310
- phpSampleConvert(className, t, lhs, args, idx, suffix) {
311
- return (0, TypeUtils_1.matchType)(t, _anyType => this.emitLine(...lhs, "'AnyType::", className, "::", args, "::" + idx, "'", suffix, "/*", "" + idx, ":", args, "*/"), _nullType => this.emitLine(...lhs, "null", suffix, " /*", "" + idx, ":", args, "*/"), _boolType => this.emitLine(...lhs, "true", suffix, " /*", "" + idx, ":", args, "*/"), _integerType => this.emitLine(...lhs, "" + idx, suffix, " /*", "" + idx, ":", args, "*/"), _doubleType => this.emitLine(...lhs, "" + (idx + idx / 1000), suffix, " /*", "" + idx, ":", args, "*/"), _stringType => this.emitLine(...lhs, "'", className, "::", args, "::" + idx, "'", suffix, " /*", "" + idx, ":", args, "*/"), arrayType => {
312
- this.emitLine(...lhs, " array(");
313
- this.indent(() => {
314
- this.phpSampleConvert(className, arrayType.items, [], [], idx, "");
315
- });
316
- this.emitLine("); /* ", "" + idx, ":", args, "*/");
317
- }, classType => this.emitLine(...lhs, this.nameForNamedType(classType), "::sample()", suffix, " /*", "" + idx, ":", args, "*/"), mapType => {
318
- this.emitBlock(["function sample(): stdClass"], () => {
319
- this.emitLine("$out = new stdClass();");
320
- this.phpSampleConvert(className, mapType.values, ["$out->{'", className, "'} = "], args, idx, ";");
321
- this.emitLine("return $out;");
322
- });
323
- this.emitLine("return sample();");
324
- }, enumType => this.emitLine(...lhs, this.nameForNamedType(enumType), "::sample()", suffix, " /*enum*/"), unionType => {
325
- const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
326
- if (nullable !== null) {
327
- this.phpSampleConvert(className, nullable, lhs, args, idx, suffix);
328
- return;
329
- }
330
- throw Error("union are not supported:" + unionType);
331
- }, transformedStringType => {
332
- if (transformedStringType.kind === "date-time") {
333
- const x = _.pad("" + (1 + (idx % 31)), 2, "0");
334
- this.emitLine(...lhs, "DateTime::createFromFormat(DateTimeInterface::ISO8601, '", `2020-12-${x}T12:${x}:${x}+00:00`, "')", suffix);
335
- // this.emitLine("return sample();");
336
- return;
337
- }
338
- throw Error('transformedStringType.kind === "unknown"');
339
- });
340
- }
341
- phpValidate(className, t, attrName, scopeAttrName) {
342
- const is = (isfn, myT = className) => {
343
- this.emitBlock(["if (!", isfn, "(", scopeAttrName, "))"], () => this.emitLine('throw new Exception("Attribute Error:', myT, "::", attrName, '");'));
344
- };
345
- return (0, TypeUtils_1.matchType)(t, _anyType => is("defined"), _nullType => is("is_null"), _boolType => is("is_bool"), _integerType => is("is_integer"), _doubleType => is("is_float"), _stringType => is("is_string"), arrayType => {
346
- is("is_array");
347
- this.emitLine("array_walk(", scopeAttrName, ", function(", scopeAttrName, "_v) {");
348
- this.indent(() => {
349
- this.phpValidate(className, arrayType.items, attrName, `${scopeAttrName}_v`);
350
- });
351
- this.emitLine("});");
352
- }, _classType => {
353
- this.emitLine(scopeAttrName, "->validate();");
354
- }, mapType => {
355
- this.emitLine("foreach (", scopeAttrName, " as $k => $v) {");
356
- this.indent(() => {
357
- this.phpValidate(className, mapType.values, attrName, "$v");
358
- });
359
- this.emitLine("}");
360
- }, enumType => {
361
- this.emitLine(this.phpType(false, enumType), "::to(", scopeAttrName, ");");
362
- }, unionType => {
363
- const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
364
- if (nullable !== null) {
365
- this.emitBlock(["if (!is_null(", scopeAttrName, "))"], () => {
366
- this.phpValidate(className, nullable, attrName, scopeAttrName);
367
- });
368
- return;
369
- }
370
- throw Error("not implemented");
371
- }, transformedStringType => {
372
- if (transformedStringType.kind === "date-time") {
373
- this.transformDateTime(className, attrName, [scopeAttrName]);
374
- return;
375
- }
376
- throw Error(`transformedStringType.kind === ${transformedStringType.kind}`);
377
- });
378
- }
379
- emitFromMethod(names, p, className, _name, desc) {
380
- this.emitLine("/**");
381
- if (desc !== undefined) {
382
- this.emitLine(" * ", desc);
383
- this.emitLine(" *");
384
- }
385
- // this.emitLine(" * @param ", this.phpType(false, p.type, false, "", "|null"));
386
- this.emitLine(" * @param ", this.phpConvertType(className, p.type), " $value");
387
- this.emitLine(" * @throws Exception");
388
- this.emitLine(" * @return ", this.phpType(false, p.type));
389
- this.emitLine(" */");
390
- this.emitBlock([
391
- "public static function ",
392
- names.from,
393
- "(",
394
- this.phpConvertType(className, p.type),
395
- " $value): ",
396
- this.phpType(false, p.type)
397
- ], () => {
398
- this.phpFromObjConvert(className, p.type, ["return "], [`$value`]);
399
- // this.emitLine("return $ret;");
400
- });
401
- }
402
- emitToMethod(names, p, className, name, desc) {
403
- this.emitLine("/**");
404
- if (desc !== undefined) {
405
- this.emitLine(" * ", desc);
406
- this.emitLine(" *");
407
- }
408
- this.emitLine(" * @throws Exception");
409
- this.emitLine(" * @return ", this.phpConvertType(className, p.type));
410
- this.emitLine(" */");
411
- this.emitBlock(["public function ", names.to, "(): ", this.phpConvertType(className, p.type)], () => {
412
- this.emitBlock(["if (", className, "::", names.validate, "($this->", name, ")) "], () => {
413
- this.phpToObjConvert(className, p.type, ["return "], ["$this->", name]);
414
- });
415
- this.emitLine("throw new Exception('never get to this ", className, "::", name, "');");
416
- });
417
- }
418
- emitValidateMethod(names, p, className, name, desc) {
419
- this.emitLine("/**");
420
- if (desc !== undefined) {
421
- this.emitLine(" * ", desc);
422
- this.emitLine(" *");
423
- }
424
- this.emitLine(" * @param ", this.phpType(false, p.type, false, "", "|null"));
425
- this.emitLine(" * @return bool");
426
- this.emitLine(" * @throws Exception");
427
- this.emitLine(" */");
428
- this.emitBlock(["public static function ", names.validate, "(", this.phpType(false, p.type), " $value): bool"], () => {
429
- this.phpValidate(className, p.type, name, `$value`);
430
- this.emitLine("return true;");
431
- });
432
- }
433
- emitGetMethod(names, p, className, name, desc) {
434
- if (this._options.withGet) {
435
- this.emitLine("/**");
436
- if (desc !== undefined) {
437
- this.emitLine(" * ", desc);
438
- this.emitLine(" *");
439
- }
440
- if (!this._options.fastGet) {
441
- this.emitLine(` * @throws Exception`);
442
- }
443
- const rendered = this.phpType(false, p.type);
444
- this.emitLine(" * @return ", rendered);
445
- this.emitLine(" */");
446
- this.emitBlock(["public function ", names.getter, "(): ", rendered], () => {
447
- if (!this._options.fastGet) {
448
- this.emitBlock(["if (", className, "::", names.validate, "($this->", name, ")) "], () => {
449
- this.emitLine("return $this->", name, ";");
450
- });
451
- this.emitLine("throw new Exception('never get to ", names.getter, " ", className, "::", name, "');");
452
- }
453
- else {
454
- this.emitLine("return $this->", name, ";");
455
- }
456
- });
457
- }
458
- }
459
- emitSetMethod(names, p, className, name, desc) {
460
- if (this._options.withSet) {
461
- this.emitLine("/**");
462
- if (desc !== undefined) {
463
- this.emitLine(" * ", desc);
464
- this.emitLine(" *");
465
- }
466
- this.emitLine(" * @param ", this.phpType(false, p.type, false, "", "|null"));
467
- this.emitLine(` * @throws Exception`);
468
- this.emitLine(" */");
469
- this.emitBlock(["public function ", names.setter, "(", this.phpType(false, p.type), " $value)"], () => {
470
- this.emitBlock(["if (", className, "::", names.validate, "($value)) "], () => {
471
- this.emitLine("$this->", name, " = $value;");
472
- });
473
- });
474
- }
475
- }
476
- emitSampleMethod(names, p, className, name, desc, idx) {
477
- if (this._options.withGet) {
478
- this.emitLine("/**");
479
- if (desc !== undefined) {
480
- this.emitLine(" * ", desc);
481
- this.emitLine(" *");
482
- }
483
- const rendered = this.phpType(false, p.type);
484
- this.emitLine(" * @return ", rendered);
485
- this.emitLine(" */");
486
- this.emitBlock(["public static function ", names.sample, "(): ", rendered], () => {
487
- this.phpSampleConvert(className, p.type, ["return "], [name], idx, ";");
488
- });
489
- }
490
- }
491
- emitClassDefinition(c, className) {
492
- this.emitFileHeader(className, []);
493
- this.emitBlock(["class ", className], () => {
494
- this.forEachClassProperty(c, "none", (name, jsonName, p) => {
495
- this.emitLine("private ", this.phpType(false, p.type), " $", name, "; // json:", jsonName, " ", p.type.isNullable ? "Optional" : "Required");
496
- });
497
- this.ensureBlankLine();
498
- const comments = [];
499
- const args = [];
500
- let prefix = "";
501
- this.forEachClassProperty(c, "none", (name, __, p) => {
502
- args.push([prefix, this.phpType(false, p.type), " $", name]);
503
- prefix = ", ";
504
- comments.push([" * @param ", this.phpType(false, p.type, false, "", "|null"), " $", name, "\n"]);
505
- });
506
- this.emitBlock(["/**\n", ...comments, " */\n", "public function __construct(", ...args, ")"], () => {
507
- this.forEachClassProperty(c, "none", name => {
508
- this.emitLine("$this->", name, " = $", name, ";");
509
- });
510
- });
511
- let idx = 31;
512
- this.forEachClassProperty(c, "leading-and-interposing", (name, jsonName, p) => {
513
- const desc = this.descriptionForClassProperty(c, jsonName);
514
- const names = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
515
- this.ensureBlankLine();
516
- this.emitFromMethod(names, p, className, name, desc);
517
- this.ensureBlankLine();
518
- this.emitToMethod(names, p, className, name, desc);
519
- this.ensureBlankLine();
520
- this.emitValidateMethod(names, p, className, name, desc);
521
- this.ensureBlankLine();
522
- this.emitGetMethod(names, p, className, name, desc);
523
- this.ensureBlankLine();
524
- this.emitSetMethod(names, p, className, name, desc);
525
- this.ensureBlankLine();
526
- this.emitSampleMethod(names, p, className, name, desc, idx++);
527
- });
528
- this.ensureBlankLine();
529
- this.emitBlock(["/**\n", ` * @throws Exception\n`, ` * @return bool\n`, " */\n", "public function validate(): bool"], () => {
530
- let lines = [];
531
- let p = "return ";
532
- this.forEachClassProperty(c, "none", (name, _jsonName, _p) => {
533
- const names = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
534
- lines.push([p, className, "::", names.validate, "($this->", name, ")"]);
535
- p = "|| ";
536
- });
537
- lines.forEach((line, jdx) => {
538
- this.emitLine(...line, lines.length === jdx + 1 ? ";" : "");
539
- });
540
- });
541
- this.ensureBlankLine();
542
- this.emitBlock([
543
- "/**\n",
544
- ` * @return stdClass\n`,
545
- ` * @throws Exception\n`,
546
- " */\n",
547
- "public function to(): stdClass "
548
- ], () => {
549
- this.emitLine("$out = new stdClass();");
550
- this.forEachClassProperty(c, "none", (name, jsonName) => {
551
- const names = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
552
- this.emitLine("$out->{'", jsonName, "'} = $this->", names.to, "();");
553
- });
554
- this.emitLine("return $out;");
555
- });
556
- this.ensureBlankLine();
557
- this.emitBlock([
558
- "/**\n",
559
- ` * @param stdClass $obj\n`,
560
- ` * @return `,
561
- className,
562
- `\n`,
563
- ` * @throws Exception\n`,
564
- " */\n",
565
- "public static function from(stdClass $obj): ",
566
- className
567
- ], () => {
568
- if (this._options.fastGet) {
569
- this.forEachClassProperty(c, "none", name => {
570
- const names = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
571
- this.emitLine(className, "::", names.validate, "($this->", name, ", true);");
572
- });
573
- }
574
- this.emitLine("return new ", className, "(");
575
- let comma = " ";
576
- this.forEachClassProperty(c, "none", (name, jsonName) => {
577
- const names = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
578
- this.emitLine(comma, className, "::", names.from, "($obj->{'", jsonName, "'})");
579
- comma = ",";
580
- });
581
- this.emitLine(");");
582
- });
583
- this.ensureBlankLine();
584
- this.emitBlock(["/**\n", " * @return ", className, "\n", " */\n", "public static function sample(): ", className], () => {
585
- this.emitLine("return new ", className, "(");
586
- let comma = " ";
587
- this.forEachClassProperty(c, "none", name => {
588
- const names = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
589
- this.emitLine(comma, className, "::", names.sample, "()");
590
- comma = ",";
591
- });
592
- this.emitLine(");");
593
- });
594
- });
595
- this.finishFile();
596
- }
597
- emitUnionAttributes(_u, _unionName) {
598
- // empty
599
- }
600
- emitUnionSerializer(_u, _unionName) {
601
- // empty
602
- }
603
- emitUnionDefinition(_u, _unionName) {
604
- throw Error("emitUnionDefinition not implemented");
605
- }
606
- emitEnumSerializationAttributes(_e) {
607
- // Empty
608
- }
609
- emitEnumDeserializationAttributes(_e) {
610
- // Empty
611
- }
612
- emitEnumDefinition(e, enumName) {
613
- this.emitFileHeader(enumName, []);
614
- this.emitDescription(this.descriptionForType(e));
615
- const caseNames = [];
616
- caseNames.push(";");
617
- const enumSerdeType = "string";
618
- this.emitBlock(["class ", enumName], () => {
619
- this.forEachEnumCase(e, "none", (name, _jsonName) => {
620
- this.emitLine("public static ", enumName, " $", name, ";");
621
- });
622
- this.emitBlock("public static function init()", () => {
623
- this.forEachEnumCase(e, "none", (name, jsonName) => {
624
- this.emitLine(enumName, "::$", name, " = new ", enumName, "('", jsonName, "');");
625
- });
626
- });
627
- this.emitLine("private ", enumSerdeType, " $enum;");
628
- this.emitBlock(["public function __construct(", enumSerdeType, " $enum)"], () => {
629
- this.emitLine("$this->enum = $enum;");
630
- });
631
- this.ensureBlankLine();
632
- this.emitEnumSerializationAttributes(e);
633
- this.emitBlock([
634
- "/**\n",
635
- ` * @param `,
636
- enumName,
637
- `\n`,
638
- ` * @return `,
639
- enumSerdeType,
640
- `\n`,
641
- ` * @throws Exception\n`,
642
- " */\n",
643
- "public static function to(",
644
- enumName,
645
- " $obj): ",
646
- enumSerdeType
647
- ], () => {
648
- this.emitLine("switch ($obj->enum) {");
649
- this.indent(() => {
650
- this.forEachEnumCase(e, "none", (name, jsonName) => {
651
- // Todo String or Number
652
- this.emitLine("case ", enumName, "::$", name, "->enum: return '", (0, exports.stringEscape)(jsonName), "';");
653
- });
654
- });
655
- this.emitLine("}");
656
- this.emitLine("throw new Exception('the give value is not an enum-value.');");
657
- });
658
- this.ensureBlankLine();
659
- this.emitEnumDeserializationAttributes(e);
660
- this.emitBlock([
661
- "/**\n",
662
- ` * @param mixed\n`,
663
- ` * @return `,
664
- enumName,
665
- "\n",
666
- ` * @throws Exception\n`,
667
- " */\n",
668
- "public static function from($obj): ",
669
- enumName
670
- ], () => {
671
- this.emitLine("switch ($obj) {");
672
- this.indent(() => {
673
- this.forEachEnumCase(e, "none", (name, jsonName) => {
674
- // Todo String or Enum
675
- this.emitLine("case '", (0, exports.stringEscape)(jsonName), "': return ", enumName, "::$", name, ";");
676
- });
677
- });
678
- this.emitLine("}");
679
- this.emitLine('throw new Exception("Cannot deserialize ', enumName, '");');
680
- });
681
- this.ensureBlankLine();
682
- this.emitBlock(["/**\n", ` * @return `, enumName, "\n", " */\n", "public static function sample(): ", enumName], () => {
683
- const lines = [];
684
- this.forEachEnumCase(e, "none", name => {
685
- lines.push([enumName, "::$", name]);
686
- });
687
- this.emitLine("return ", lines[0], ";");
688
- });
689
- });
690
- this.emitLine(enumName, "::init();");
691
- this.finishFile();
692
- }
693
- emitSourceStructure(givenFilename) {
694
- this.emitLine("<?php");
695
- this.forEachNamedType("leading-and-interposing", (c, n) => this.emitClassDefinition(c, n), (e, n) => this.emitEnumDefinition(e, n), (u, n) => this.emitUnionDefinition(u, n));
696
- if (this._options.withClosing) {
697
- this.emitLine("?>");
698
- }
699
- super.finishFile((0, Support_1.defined)(givenFilename));
700
- }
701
- }
702
- exports.PhpRenderer = PhpRenderer;