[php-flight] fix: remove trailing spaces

According to the Guidelines for Contributing
(https://github.com/OpenAPITools/openapi-generator/blob/master/CONTRIBUTING.md)
generated PHP code should conform to PSR-12
(https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-extended-coding-style-guide.md).

There are some minor violations regarding the following rule

> There MUST NOT be trailing whitespace at the end of lines.

This change removes trailing spaces in generated code.
This commit is contained in:
Jonas Renggli 2025-05-09 12:03:23 +02:00
parent d6c4634269
commit 065c6ed855
13 changed files with 86 additions and 86 deletions

View File

@ -21,31 +21,31 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}} impl
return new self(
{{#vars}}
{{#isDateTime}}
isset($data['{{baseName}}']) ? new \DateTime($data['{{baseName}}']) : null{{^last}}, {{/last}}
isset($data['{{baseName}}']) ? new \DateTime($data['{{baseName}}']) : null{{^last}},{{/last}}
{{/isDateTime}}
{{#isEnum}}
isset($data['{{baseName}}']) ? {{enumName}}::tryFrom($data['{{baseName}}']) : null{{^last}}, {{/last}}
isset($data['{{baseName}}']) ? {{enumName}}::tryFrom($data['{{baseName}}']) : null{{^last}},{{/last}}
{{/isEnum}}
{{#isEnumRef}}
isset($data['{{baseName}}']) ? {{complexType}}::tryFrom($data['{{baseName}}']) : null{{^last}}, {{/last}}
isset($data['{{baseName}}']) ? {{complexType}}::tryFrom($data['{{baseName}}']) : null{{^last}},{{/last}}
{{/isEnumRef}}
{{#isModel}}
isset($data['{{baseName}}']) ? {{complexType}}::fromArray($data['{{baseName}}']) : null{{^last}}, {{/last}}
isset($data['{{baseName}}']) ? {{complexType}}::fromArray($data['{{baseName}}']) : null{{^last}},{{/last}}
{{/isModel}}
{{#isArray}}
{{#items.isEnumRef}}
isset($data['{{baseName}}']) ? array_map(fn($item) => {{items.complexType}}::tryFrom($item), $data['{{baseName}}']) : null{{^last}}, {{/last}}
isset($data['{{baseName}}']) ? array_map(fn($item) => {{items.complexType}}::tryFrom($item), $data['{{baseName}}']) : null{{^last}},{{/last}}
{{/items.isEnumRef}}
{{#items.isModel}}
isset($data['{{baseName}}']) ? array_map(fn($item) => {{items.complexType}}::fromArray($item), $data['{{baseName}}']) : null{{^last}}, {{/last}}
isset($data['{{baseName}}']) ? array_map(fn($item) => {{items.complexType}}::fromArray($item), $data['{{baseName}}']) : null{{^last}},{{/last}}
{{/items.isModel}}
{{#items.isDateTime}}
isset($data['{{baseName}}']) ? array_map(fn($item) => new \DateTime($item), $data['{{baseName}}']) : null{{^last}}, {{/last}}
isset($data['{{baseName}}']) ? array_map(fn($item) => new \DateTime($item), $data['{{baseName}}']) : null{{^last}},{{/last}}
{{/items.isDateTime}}
{{^items.isEnumRef}}
{{^items.isModel}}
{{^items.isDateTime}}
$data['{{baseName}}'] ?? null{{^last}}, {{/last}}
$data['{{baseName}}'] ?? null{{^last}},{{/last}}
{{/items.isDateTime}}
{{/items.isModel}}
{{/items.isEnumRef}}
@ -55,7 +55,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}} impl
{{^isModel}}
{{^isArray}}
{{^isDateTime}}
$data['{{baseName}}'] ?? null{{^last}}, {{/last}}
$data['{{baseName}}'] ?? null{{^last}},{{/last}}
{{/isDateTime}}
{{/isArray}}
{{/isModel}}
@ -69,19 +69,19 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}} impl
return [
{{#vars}}
{{#isDateTime}}
'{{baseName}}' => $this->{{name}}?->format('c'){{^last}}, {{/last}}
'{{baseName}}' => $this->{{name}}?->format('c'){{^last}},{{/last}}
{{/isDateTime}}
{{#isArray}}
{{#items.isDateTime}}
'{{baseName}}' => $this->{{name}} ? array_map(fn($item) => $item->format('c'), $this->{{name}}) : null{{^last}}, {{/last}}
'{{baseName}}' => $this->{{name}} ? array_map(fn($item) => $item->format('c'), $this->{{name}}) : null{{^last}},{{/last}}
{{/items.isDateTime}}
{{^items.isDateTime}}
'{{baseName}}' => $this->{{name}}{{^last}}, {{/last}}
'{{baseName}}' => $this->{{name}}{{^last}},{{/last}}
{{/items.isDateTime}}
{{/isArray}}
{{^isDateTime}}
{{^isArray}}
'{{baseName}}' => $this->{{name}}{{^last}}, {{/last}}
'{{baseName}}' => $this->{{name}}{{^last}},{{/last}}
{{/isArray}}
{{/isDateTime}}
{{/vars}}

View File

@ -7,8 +7,8 @@
* {{{.}}}
*
{{/appDescription}}
* {{#version}}The version of the OpenAPI document: {{{.}}}{{/version}}
* {{#infoEmail}}Contact: {{{.}}}{{/infoEmail}}
*{{#version}} The version of the OpenAPI document: {{{.}}}{{/version}}
*{{#infoEmail}} Contact: {{{.}}}{{/infoEmail}}
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/

View File

@ -22,7 +22,7 @@ class RegisterRoutes {
$r = \Flight::request();
{{^vendorExtensions.x-return-type-is-void}}$result = {{/vendorExtensions.x-return-type-is-void}}$handler->{{operationId}}(
{{#vendorExtensions.x-nonFormParams}}
parseParam({{#isBodyParam}}json_decode($r->getBody(), true){{/isBodyParam}}{{#isQueryParam}}$r->query['{{baseName}}'] ?? null{{/isQueryParam}}{{#isPathParam}}${{paramName}}{{/isPathParam}}{{#isHeaderParam}}$r->getHeader('{{baseName}}'){{/isHeaderParam}}, '{{vendorExtensions.x-comment-type-escaped}}'){{^-last}}, {{/-last}}
parseParam({{#isBodyParam}}json_decode($r->getBody(), true){{/isBodyParam}}{{#isQueryParam}}$r->query['{{baseName}}'] ?? null{{/isQueryParam}}{{#isPathParam}}${{paramName}}{{/isPathParam}}{{#isHeaderParam}}$r->getHeader('{{baseName}}'){{/isHeaderParam}}, '{{vendorExtensions.x-comment-type-escaped}}'){{^-last}},{{/-last}}
{{/vendorExtensions.x-nonFormParams}}
);
{{^vendorExtensions.x-return-type-is-void}}
@ -42,7 +42,7 @@ class RegisterRoutes {
$r = \Flight::request();
$handler->{{operationId}}Stream(
{{#vendorExtensions.x-nonFormParams}}
parseParam({{#isBodyParam}}json_decode($r->getBody(), true){{/isBodyParam}}{{#isQueryParam}}$r->query['{{baseName}}'] ?? null{{/isQueryParam}}{{#isPathParam}}${{paramName}}{{/isPathParam}}{{#isHeaderParam}}$r->getHeader('{{baseName}}'){{/isHeaderParam}}, '{{vendorExtensions.x-comment-type-escaped}}'){{^-last}}, {{/-last}}
parseParam({{#isBodyParam}}json_decode($r->getBody(), true){{/isBodyParam}}{{#isQueryParam}}$r->query['{{baseName}}'] ?? null{{/isQueryParam}}{{#isPathParam}}${{paramName}}{{/isPathParam}}{{#isHeaderParam}}$r->getHeader('{{baseName}}'){{/isHeaderParam}}, '{{vendorExtensions.x-comment-type-escaped}}'){{^-last}},{{/-last}}
{{/vendorExtensions.x-nonFormParams}}
);
// ignore return value: streaming expected

View File

@ -16,7 +16,7 @@
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
@ -76,17 +76,17 @@ class ApiResponse implements \JsonSerializable
public static function fromArray(array $data): self
{
return new self(
$data['code'] ?? null,
$data['type'] ?? null,
$data['message'] ?? null,
$data['code'] ?? null,
$data['type'] ?? null,
$data['message'] ?? null,
);
}
public function jsonSerialize(): mixed {
return [
'code' => $this->code,
'type' => $this->type,
'message' => $this->message,
'code' => $this->code,
'type' => $this->type,
'message' => $this->message,
];
}
}

View File

@ -16,7 +16,7 @@
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
@ -67,15 +67,15 @@ class Category implements \JsonSerializable
public static function fromArray(array $data): self
{
return new self(
$data['id'] ?? null,
$data['name'] ?? null,
$data['id'] ?? null,
$data['name'] ?? null,
);
}
public function jsonSerialize(): mixed {
return [
'id' => $this->id,
'name' => $this->name,
'id' => $this->id,
'name' => $this->name,
];
}
}

View File

@ -16,7 +16,7 @@
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/

View File

@ -16,7 +16,7 @@
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
@ -106,23 +106,23 @@ class Order implements \JsonSerializable
public static function fromArray(array $data): self
{
return new self(
$data['id'] ?? null,
$data['petId'] ?? null,
$data['quantity'] ?? null,
isset($data['shipDate']) ? new \DateTime($data['shipDate']) : null,
isset($data['status']) ? OrderStatus::tryFrom($data['status']) : null,
$data['complete'] ?? null,
$data['id'] ?? null,
$data['petId'] ?? null,
$data['quantity'] ?? null,
isset($data['shipDate']) ? new \DateTime($data['shipDate']) : null,
isset($data['status']) ? OrderStatus::tryFrom($data['status']) : null,
$data['complete'] ?? null,
);
}
public function jsonSerialize(): mixed {
return [
'id' => $this->id,
'petId' => $this->petId,
'quantity' => $this->quantity,
'shipDate' => $this->shipDate?->format('c'),
'status' => $this->status,
'complete' => $this->complete,
'id' => $this->id,
'petId' => $this->petId,
'quantity' => $this->quantity,
'shipDate' => $this->shipDate?->format('c'),
'status' => $this->status,
'complete' => $this->complete,
];
}
}

View File

@ -16,7 +16,7 @@
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/

View File

@ -16,7 +16,7 @@
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
@ -112,23 +112,23 @@ class Pet implements \JsonSerializable
public static function fromArray(array $data): self
{
return new self(
$data['id'] ?? null,
isset($data['category']) ? Category::fromArray($data['category']) : null,
$data['name'] ?? null,
$data['photoUrls'] ?? null,
isset($data['tags']) ? array_map(fn($item) => Tag::fromArray($item), $data['tags']) : null,
isset($data['status']) ? PetStatus::tryFrom($data['status']) : null,
$data['id'] ?? null,
isset($data['category']) ? Category::fromArray($data['category']) : null,
$data['name'] ?? null,
$data['photoUrls'] ?? null,
isset($data['tags']) ? array_map(fn($item) => Tag::fromArray($item), $data['tags']) : null,
isset($data['status']) ? PetStatus::tryFrom($data['status']) : null,
);
}
public function jsonSerialize(): mixed {
return [
'id' => $this->id,
'category' => $this->category,
'name' => $this->name,
'photoUrls' => $this->photoUrls,
'tags' => $this->tags,
'status' => $this->status,
'id' => $this->id,
'category' => $this->category,
'name' => $this->name,
'photoUrls' => $this->photoUrls,
'tags' => $this->tags,
'status' => $this->status,
];
}
}

View File

@ -16,7 +16,7 @@
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/

View File

@ -16,7 +16,7 @@
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
@ -66,15 +66,15 @@ class Tag implements \JsonSerializable
public static function fromArray(array $data): self
{
return new self(
$data['id'] ?? null,
$data['name'] ?? null,
$data['id'] ?? null,
$data['name'] ?? null,
);
}
public function jsonSerialize(): mixed {
return [
'id' => $this->id,
'name' => $this->name,
'id' => $this->id,
'name' => $this->name,
];
}
}

View File

@ -16,7 +16,7 @@
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
@ -128,27 +128,27 @@ class User implements \JsonSerializable
public static function fromArray(array $data): self
{
return new self(
$data['id'] ?? null,
$data['username'] ?? null,
$data['firstName'] ?? null,
$data['lastName'] ?? null,
$data['email'] ?? null,
$data['password'] ?? null,
$data['phone'] ?? null,
$data['userStatus'] ?? null,
$data['id'] ?? null,
$data['username'] ?? null,
$data['firstName'] ?? null,
$data['lastName'] ?? null,
$data['email'] ?? null,
$data['password'] ?? null,
$data['phone'] ?? null,
$data['userStatus'] ?? null,
);
}
public function jsonSerialize(): mixed {
return [
'id' => $this->id,
'username' => $this->username,
'firstName' => $this->firstName,
'lastName' => $this->lastName,
'email' => $this->email,
'password' => $this->password,
'phone' => $this->phone,
'userStatus' => $this->userStatus,
'id' => $this->id,
'username' => $this->username,
'firstName' => $this->firstName,
'lastName' => $this->lastName,
'email' => $this->email,
'password' => $this->password,
'phone' => $this->phone,
'userStatus' => $this->userStatus,
];
}
}

View File

@ -56,7 +56,7 @@ class RegisterRoutes {
\Flight::route('DELETE /pet/@petId', function (string $petId) use ($handler) {
$r = \Flight::request();
$handler->deletePet(
parseParam($petId, 'int'),
parseParam($petId, 'int'),
parseParam($r->getHeader('api_key'), '?string')
);
\Flight::halt(400);
@ -66,7 +66,7 @@ class RegisterRoutes {
\Flight::route('DELETE /pet/@petId', function (string $petId) use ($handler) {
$r = \Flight::request();
$handler->deletePetStream(
parseParam($petId, 'int'),
parseParam($petId, 'int'),
parseParam($r->getHeader('api_key'), '?string')
);
// ignore return value: streaming expected
@ -440,7 +440,7 @@ class RegisterRoutes {
\Flight::route('GET /user/login', function () use ($handler) {
$r = \Flight::request();
$result = $handler->loginUser(
parseParam($r->query['username'] ?? null, 'string'),
parseParam($r->query['username'] ?? null, 'string'),
parseParam($r->query['password'] ?? null, 'string')
);
if ($result === null) {
@ -454,7 +454,7 @@ class RegisterRoutes {
\Flight::route('GET /user/login', function () use ($handler) {
$r = \Flight::request();
$handler->loginUserStream(
parseParam($r->query['username'] ?? null, 'string'),
parseParam($r->query['username'] ?? null, 'string'),
parseParam($r->query['password'] ?? null, 'string')
);
// ignore return value: streaming expected
@ -488,7 +488,7 @@ class RegisterRoutes {
\Flight::route('PUT /user/@username', function (string $username) use ($handler) {
$r = \Flight::request();
$handler->updateUser(
parseParam($username, 'string'),
parseParam($username, 'string'),
parseParam(json_decode($r->getBody(), true), '\\OpenAPIServer\\Model\\User')
);
\Flight::halt(400);
@ -498,7 +498,7 @@ class RegisterRoutes {
\Flight::route('PUT /user/@username', function (string $username) use ($handler) {
$r = \Flight::request();
$handler->updateUserStream(
parseParam($username, 'string'),
parseParam($username, 'string'),
parseParam(json_decode($r->getBody(), true), '\\OpenAPIServer\\Model\\User')
);
// ignore return value: streaming expected