Skip to content

Commit a86bd41

Browse files
authored
[php-nextgen]: Inherit model method docs and fix interface types (#23307)
Co-authored-by: coffeemakr <coffeemakr@users.noreply.github.com>
1 parent 3cf653d commit a86bd41

75 files changed

Lines changed: 746 additions & 2446 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

modules/openapi-generator/src/main/resources/php-nextgen/ModelInterface.mustache

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,50 +37,51 @@ interface ModelInterface
3737
/**
3838
* Array of property to type mappings. Used for (de)serialization
3939
*
40-
* @return array
40+
* @return array<string,string>
4141
*/
4242
public static function openAPITypes(): array;
4343
4444
/**
4545
* Array of property to format mappings. Used for (de)serialization
4646
*
47-
* @return array
47+
* @return array<string,string|null>
4848
*/
4949
public static function openAPIFormats(): array;
5050
5151
/**
52-
* Array of attributes where the key is the local name, and the value is the original name
52+
* Array of attributes where the key is the local name,
53+
* and the value is the original name
5354
*
54-
* @return array
55+
* @return array<string,string>
5556
*/
5657
public static function attributeMap(): array;
5758
5859
/**
5960
* Array of attributes to setter functions (for deserialization of responses)
6061
*
61-
* @return array
62+
* @return array<string,string>
6263
*/
6364
public static function setters(): array;
6465
6566
/**
6667
* Array of attributes to getter functions (for serialization of requests)
6768
*
68-
* @return array
69+
* @return array<string,string>
6970
*/
7071
public static function getters(): array;
7172
7273
/**
7374
* Show all the invalid properties with reasons.
7475
*
75-
* @return array
76+
* @return string[] invalid properties with reasons
7677
*/
7778
public function listInvalidProperties(): array;
7879
7980
/**
8081
* Validate all the properties in the model
8182
* return true if all passed
8283
*
83-
* @return bool
84+
* @return bool True if all properties are valid
8485
*/
8586
public function valid(): bool;
8687

modules/openapi-generator/src/main/resources/php-nextgen/model_generic.mustache

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,15 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}}{{/parentSchema}}{{^par
4747
protected array $openAPINullablesSetToNull = [];
4848

4949
/**
50-
* Array of property to type mappings. Used for (de)serialization
51-
*
52-
* @return array<string, string>
50+
* {@inheritdoc}
5351
*/
5452
public static function openAPITypes(): array
5553
{
5654
return self::$openAPITypes{{#parentSchema}} + parent::openAPITypes(){{/parentSchema}};
5755
}
5856

5957
/**
60-
* Array of property to format mappings. Used for (de)serialization
61-
*
62-
* @return array<string, string>
58+
* {@inheritdoc}
6359
*/
6460
public static function openAPIFormats(): array
6561
{
@@ -97,21 +93,15 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}}{{/parentSchema}}{{^par
9793
}
9894

9995
/**
100-
* Checks if a property is nullable
101-
*
102-
* @param string $property
103-
* @return bool
96+
* {@inheritdoc}
10497
*/
10598
public static function isNullable(string $property): bool
10699
{
107100
return self::openAPINullables()[$property] ?? false;
108101
}
109102

110103
/**
111-
* Checks if a nullable property is set to null.
112-
*
113-
* @param string $property
114-
* @return bool
104+
* {@inheritdoc}
115105
*/
116106
public function isNullableSetToNull(string $property): bool
117107
{
@@ -150,40 +140,31 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}}{{/parentSchema}}{{^par
150140
];
151141

152142
/**
153-
* Array of attributes where the key is the local name,
154-
* and the value is the original name
155-
*
156-
* @return array<string, string>
143+
* {@inheritdoc}
157144
*/
158145
public static function attributeMap(): array
159146
{
160147
return {{#parentSchema}}parent::attributeMap() + {{/parentSchema}}self::$attributeMap;
161148
}
162149

163150
/**
164-
* Array of attributes to setter functions (for deserialization of responses)
165-
*
166-
* @return array<string, string>
151+
* {@inheritdoc}
167152
*/
168153
public static function setters(): array
169154
{
170155
return {{#parentSchema}}parent::setters() + {{/parentSchema}}self::$setters;
171156
}
172157

173158
/**
174-
* Array of attributes to getter functions (for serialization of requests)
175-
*
176-
* @return array<string, string>
159+
* {@inheritdoc}
177160
*/
178161
public static function getters(): array
179162
{
180163
return {{#parentSchema}}parent::getters() + {{/parentSchema}}self::$getters;
181164
}
182165

183166
/**
184-
* The original name of the model.
185-
*
186-
* @return string
167+
* {@inheritdoc}
187168
*/
188169
public function getModelName(): string
189170
{
@@ -280,9 +261,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}}{{/parentSchema}}{{^par
280261
}
281262

282263
/**
283-
* Show all the invalid properties with reasons.
284-
*
285-
* @return string[] invalid properties with reasons
264+
* {@inheritdoc}
286265
*/
287266
public function listInvalidProperties(): array
288267
{
@@ -361,10 +340,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}}{{/parentSchema}}{{^par
361340
}
362341

363342
/**
364-
* Validate all the properties in the model
365-
* return true if all passed
366-
*
367-
* @return bool True if all properties are valid
343+
* {@inheritdoc}
368344
*/
369345
public function valid(): bool
370346
{

samples/client/echo_api/php-nextgen-streaming/src/Model/Bird.php

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,15 @@ class Bird implements ModelInterface, ArrayAccess, JsonSerializable
9191
protected array $openAPINullablesSetToNull = [];
9292

9393
/**
94-
* Array of property to type mappings. Used for (de)serialization
95-
*
96-
* @return array<string, string>
94+
* {@inheritdoc}
9795
*/
9896
public static function openAPITypes(): array
9997
{
10098
return self::$openAPITypes;
10199
}
102100

103101
/**
104-
* Array of property to format mappings. Used for (de)serialization
105-
*
106-
* @return array<string, string>
102+
* {@inheritdoc}
107103
*/
108104
public static function openAPIFormats(): array
109105
{
@@ -141,21 +137,15 @@ private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull):
141137
}
142138

143139
/**
144-
* Checks if a property is nullable
145-
*
146-
* @param string $property
147-
* @return bool
140+
* {@inheritdoc}
148141
*/
149142
public static function isNullable(string $property): bool
150143
{
151144
return self::openAPINullables()[$property] ?? false;
152145
}
153146

154147
/**
155-
* Checks if a nullable property is set to null.
156-
*
157-
* @param string $property
158-
* @return bool
148+
* {@inheritdoc}
159149
*/
160150
public function isNullableSetToNull(string $property): bool
161151
{
@@ -194,40 +184,31 @@ public function isNullableSetToNull(string $property): bool
194184
];
195185

196186
/**
197-
* Array of attributes where the key is the local name,
198-
* and the value is the original name
199-
*
200-
* @return array<string, string>
187+
* {@inheritdoc}
201188
*/
202189
public static function attributeMap(): array
203190
{
204191
return self::$attributeMap;
205192
}
206193

207194
/**
208-
* Array of attributes to setter functions (for deserialization of responses)
209-
*
210-
* @return array<string, string>
195+
* {@inheritdoc}
211196
*/
212197
public static function setters(): array
213198
{
214199
return self::$setters;
215200
}
216201

217202
/**
218-
* Array of attributes to getter functions (for serialization of requests)
219-
*
220-
* @return array<string, string>
203+
* {@inheritdoc}
221204
*/
222205
public static function getters(): array
223206
{
224207
return self::$getters;
225208
}
226209

227210
/**
228-
* The original name of the model.
229-
*
230-
* @return string
211+
* {@inheritdoc}
231212
*/
232213
public function getModelName(): string
233214
{
@@ -272,9 +253,7 @@ private function setIfExists(string $variableName, array $fields, mixed $default
272253
}
273254

274255
/**
275-
* Show all the invalid properties with reasons.
276-
*
277-
* @return string[] invalid properties with reasons
256+
* {@inheritdoc}
278257
*/
279258
public function listInvalidProperties(): array
280259
{
@@ -284,10 +263,7 @@ public function listInvalidProperties(): array
284263
}
285264

286265
/**
287-
* Validate all the properties in the model
288-
* return true if all passed
289-
*
290-
* @return bool True if all properties are valid
266+
* {@inheritdoc}
291267
*/
292268
public function valid(): bool
293269
{

0 commit comments

Comments
 (0)