[php-nextgen] minor fix to return type (#16752)

* minor fix to return type

* use returnProperty
This commit is contained in:
William Cheng 2023-10-08 15:29:16 +08:00 committed by GitHub
parent f5680019b2
commit 5fb6fcf9ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 5 deletions

1
.gitignore vendored
View File

@ -193,6 +193,7 @@ samples/server/petstore/php-slim4/composer.lock
samples/server/petstore/php-symfony/SymfonyBundle-php/composer.lock
samples/server/petstore/php-mezzio-ph/composer.lock
samples/server/petstore/php-mezzio-ph-modern/composer.lock
samples/client/petstore/php-nextgen/OpenAPIClient-php/.phplint.cache/
# ts
samples/client/petstore/typescript-angular2/npm/npm-debug.log

View File

@ -170,7 +170,11 @@ public class PhpNextgenClientCodegen extends AbstractPhpCodegen {
if (operation.returnType == null) {
operation.vendorExtensions.putIfAbsent("x-php-return-type", "void");
} else {
operation.vendorExtensions.putIfAbsent("x-php-return-type", operation.returnType);
if (operation.returnProperty.isContainer) { // array or map
operation.vendorExtensions.putIfAbsent("x-php-return-type", "array");
} else {
operation.vendorExtensions.putIfAbsent("x-php-return-type", operation.returnType);
}
}
for (CodegenParameter param : operation.allParams) {

View File

@ -187,7 +187,7 @@ use {{invokerPackage}}\ObjectSerializer;
{{#vendorExtensions.x-group-parameters}}
array $associative_array
{{/vendorExtensions.x-group-parameters}}
): {{vendorExtensions.x-php-return-type}}
): {{{vendorExtensions.x-php-return-type}}}
{
{{#returnType}}list($response) = {{/returnType}}$this->{{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});{{#returnType}}
return $response;{{/returnType}}

View File

@ -0,0 +1,13 @@
path:
- src/
- tests/
jobs: 10
extensions:
- php
exclude:
- vendor
warning: true
memory-limit: -1
no-cache: false
log-json: false
log-junit: false

View File

@ -827,7 +827,7 @@ class PetApi
public function findPetsByStatus(
array $status,
string $contentType = self::contentTypes['findPetsByStatus'][0]
): \OpenAPI\Client\Model\Pet[]
): array
{
list($response) = $this->findPetsByStatusWithHttpInfo($status, $contentType);
return $response;
@ -1131,7 +1131,7 @@ class PetApi
public function findPetsByTags(
array $tags,
string $contentType = self::contentTypes['findPetsByTags'][0]
): \OpenAPI\Client\Model\Pet[]
): array
{
list($response) = $this->findPetsByTagsWithHttpInfo($tags, $contentType);
return $response;

View File

@ -390,7 +390,7 @@ class StoreApi
*/
public function getInventory(
string $contentType = self::contentTypes['getInventory'][0]
): array<string,int>
): array
{
list($response) = $this->getInventoryWithHttpInfo($contentType);
return $response;