[php-flight] fix: remove trailing spaces (#21254)

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-11 16:32:27 +02:00 committed by GitHub
parent 2fd1ee66cc
commit be17698320
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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( return new self(
{{#vars}} {{#vars}}
{{#isDateTime}} {{#isDateTime}}
isset($data['{{baseName}}']) ? new \DateTime($data['{{baseName}}']) : null{{^last}}, {{/last}} isset($data['{{baseName}}']) ? new \DateTime($data['{{baseName}}']) : null{{^last}},{{/last}}
{{/isDateTime}} {{/isDateTime}}
{{#isEnum}} {{#isEnum}}
isset($data['{{baseName}}']) ? {{enumName}}::tryFrom($data['{{baseName}}']) : null{{^last}}, {{/last}} isset($data['{{baseName}}']) ? {{enumName}}::tryFrom($data['{{baseName}}']) : null{{^last}},{{/last}}
{{/isEnum}} {{/isEnum}}
{{#isEnumRef}} {{#isEnumRef}}
isset($data['{{baseName}}']) ? {{complexType}}::tryFrom($data['{{baseName}}']) : null{{^last}}, {{/last}} isset($data['{{baseName}}']) ? {{complexType}}::tryFrom($data['{{baseName}}']) : null{{^last}},{{/last}}
{{/isEnumRef}} {{/isEnumRef}}
{{#isModel}} {{#isModel}}
isset($data['{{baseName}}']) ? {{complexType}}::fromArray($data['{{baseName}}']) : null{{^last}}, {{/last}} isset($data['{{baseName}}']) ? {{complexType}}::fromArray($data['{{baseName}}']) : null{{^last}},{{/last}}
{{/isModel}} {{/isModel}}
{{#isArray}} {{#isArray}}
{{#items.isEnumRef}} {{#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.isEnumRef}}
{{#items.isModel}} {{#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.isModel}}
{{#items.isDateTime}} {{#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.isDateTime}}
{{^items.isEnumRef}} {{^items.isEnumRef}}
{{^items.isModel}} {{^items.isModel}}
{{^items.isDateTime}} {{^items.isDateTime}}
$data['{{baseName}}'] ?? null{{^last}}, {{/last}} $data['{{baseName}}'] ?? null{{^last}},{{/last}}
{{/items.isDateTime}} {{/items.isDateTime}}
{{/items.isModel}} {{/items.isModel}}
{{/items.isEnumRef}} {{/items.isEnumRef}}
@ -55,7 +55,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}} impl
{{^isModel}} {{^isModel}}
{{^isArray}} {{^isArray}}
{{^isDateTime}} {{^isDateTime}}
$data['{{baseName}}'] ?? null{{^last}}, {{/last}} $data['{{baseName}}'] ?? null{{^last}},{{/last}}
{{/isDateTime}} {{/isDateTime}}
{{/isArray}} {{/isArray}}
{{/isModel}} {{/isModel}}
@ -69,19 +69,19 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}} impl
return [ return [
{{#vars}} {{#vars}}
{{#isDateTime}} {{#isDateTime}}
'{{baseName}}' => $this->{{name}}?->format('c'){{^last}}, {{/last}} '{{baseName}}' => $this->{{name}}?->format('c'){{^last}},{{/last}}
{{/isDateTime}} {{/isDateTime}}
{{#isArray}} {{#isArray}}
{{#items.isDateTime}} {{#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}}
{{^items.isDateTime}} {{^items.isDateTime}}
'{{baseName}}' => $this->{{name}}{{^last}}, {{/last}} '{{baseName}}' => $this->{{name}}{{^last}},{{/last}}
{{/items.isDateTime}} {{/items.isDateTime}}
{{/isArray}} {{/isArray}}
{{^isDateTime}} {{^isDateTime}}
{{^isArray}} {{^isArray}}
'{{baseName}}' => $this->{{name}}{{^last}}, {{/last}} '{{baseName}}' => $this->{{name}}{{^last}},{{/last}}
{{/isArray}} {{/isArray}}
{{/isDateTime}} {{/isDateTime}}
{{/vars}} {{/vars}}

View File

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

View File

@ -22,7 +22,7 @@ class RegisterRoutes {
$r = \Flight::request(); $r = \Flight::request();
{{^vendorExtensions.x-return-type-is-void}}$result = {{/vendorExtensions.x-return-type-is-void}}$handler->{{operationId}}( {{^vendorExtensions.x-return-type-is-void}}$result = {{/vendorExtensions.x-return-type-is-void}}$handler->{{operationId}}(
{{#vendorExtensions.x-nonFormParams}} {{#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-nonFormParams}}
); );
{{^vendorExtensions.x-return-type-is-void}} {{^vendorExtensions.x-return-type-is-void}}
@ -42,7 +42,7 @@ class RegisterRoutes {
$r = \Flight::request(); $r = \Flight::request();
$handler->{{operationId}}Stream( $handler->{{operationId}}Stream(
{{#vendorExtensions.x-nonFormParams}} {{#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-nonFormParams}}
); );
// ignore return value: streaming expected // 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. * 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 * The version of the OpenAPI document: 1.0.0
* *
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
* *
*/ */
@ -76,17 +76,17 @@ class ApiResponse implements \JsonSerializable
public static function fromArray(array $data): self public static function fromArray(array $data): self
{ {
return new self( return new self(
$data['code'] ?? null, $data['code'] ?? null,
$data['type'] ?? null, $data['type'] ?? null,
$data['message'] ?? null, $data['message'] ?? null,
); );
} }
public function jsonSerialize(): mixed { public function jsonSerialize(): mixed {
return [ return [
'code' => $this->code, 'code' => $this->code,
'type' => $this->type, 'type' => $this->type,
'message' => $this->message, '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. * 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 * The version of the OpenAPI document: 1.0.0
* *
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
* *
*/ */
@ -67,15 +67,15 @@ class Category implements \JsonSerializable
public static function fromArray(array $data): self public static function fromArray(array $data): self
{ {
return new self( return new self(
$data['id'] ?? null, $data['id'] ?? null,
$data['name'] ?? null, $data['name'] ?? null,
); );
} }
public function jsonSerialize(): mixed { public function jsonSerialize(): mixed {
return [ return [
'id' => $this->id, 'id' => $this->id,
'name' => $this->name, '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. * 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 * The version of the OpenAPI document: 1.0.0
* *
* Generated by: https://github.com/openapitools/openapi-generator.git * 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. * 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 * The version of the OpenAPI document: 1.0.0
* *
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
* *
*/ */
@ -106,23 +106,23 @@ class Order implements \JsonSerializable
public static function fromArray(array $data): self public static function fromArray(array $data): self
{ {
return new self( return new self(
$data['id'] ?? null, $data['id'] ?? null,
$data['petId'] ?? null, $data['petId'] ?? null,
$data['quantity'] ?? null, $data['quantity'] ?? null,
isset($data['shipDate']) ? new \DateTime($data['shipDate']) : null, isset($data['shipDate']) ? new \DateTime($data['shipDate']) : null,
isset($data['status']) ? OrderStatus::tryFrom($data['status']) : null, isset($data['status']) ? OrderStatus::tryFrom($data['status']) : null,
$data['complete'] ?? null, $data['complete'] ?? null,
); );
} }
public function jsonSerialize(): mixed { public function jsonSerialize(): mixed {
return [ return [
'id' => $this->id, 'id' => $this->id,
'petId' => $this->petId, 'petId' => $this->petId,
'quantity' => $this->quantity, 'quantity' => $this->quantity,
'shipDate' => $this->shipDate?->format('c'), 'shipDate' => $this->shipDate?->format('c'),
'status' => $this->status, 'status' => $this->status,
'complete' => $this->complete, '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. * 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 * The version of the OpenAPI document: 1.0.0
* *
* Generated by: https://github.com/openapitools/openapi-generator.git * 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. * 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 * The version of the OpenAPI document: 1.0.0
* *
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
* *
*/ */
@ -112,23 +112,23 @@ class Pet implements \JsonSerializable
public static function fromArray(array $data): self public static function fromArray(array $data): self
{ {
return new self( return new self(
$data['id'] ?? null, $data['id'] ?? null,
isset($data['category']) ? Category::fromArray($data['category']) : null, isset($data['category']) ? Category::fromArray($data['category']) : null,
$data['name'] ?? null, $data['name'] ?? null,
$data['photoUrls'] ?? null, $data['photoUrls'] ?? null,
isset($data['tags']) ? array_map(fn($item) => Tag::fromArray($item), $data['tags']) : null, isset($data['tags']) ? array_map(fn($item) => Tag::fromArray($item), $data['tags']) : null,
isset($data['status']) ? PetStatus::tryFrom($data['status']) : null, isset($data['status']) ? PetStatus::tryFrom($data['status']) : null,
); );
} }
public function jsonSerialize(): mixed { public function jsonSerialize(): mixed {
return [ return [
'id' => $this->id, 'id' => $this->id,
'category' => $this->category, 'category' => $this->category,
'name' => $this->name, 'name' => $this->name,
'photoUrls' => $this->photoUrls, 'photoUrls' => $this->photoUrls,
'tags' => $this->tags, 'tags' => $this->tags,
'status' => $this->status, '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. * 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 * The version of the OpenAPI document: 1.0.0
* *
* Generated by: https://github.com/openapitools/openapi-generator.git * 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. * 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 * The version of the OpenAPI document: 1.0.0
* *
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
* *
*/ */
@ -66,15 +66,15 @@ class Tag implements \JsonSerializable
public static function fromArray(array $data): self public static function fromArray(array $data): self
{ {
return new self( return new self(
$data['id'] ?? null, $data['id'] ?? null,
$data['name'] ?? null, $data['name'] ?? null,
); );
} }
public function jsonSerialize(): mixed { public function jsonSerialize(): mixed {
return [ return [
'id' => $this->id, 'id' => $this->id,
'name' => $this->name, '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. * 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 * The version of the OpenAPI document: 1.0.0
* *
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
* *
*/ */
@ -128,27 +128,27 @@ class User implements \JsonSerializable
public static function fromArray(array $data): self public static function fromArray(array $data): self
{ {
return new self( return new self(
$data['id'] ?? null, $data['id'] ?? null,
$data['username'] ?? null, $data['username'] ?? null,
$data['firstName'] ?? null, $data['firstName'] ?? null,
$data['lastName'] ?? null, $data['lastName'] ?? null,
$data['email'] ?? null, $data['email'] ?? null,
$data['password'] ?? null, $data['password'] ?? null,
$data['phone'] ?? null, $data['phone'] ?? null,
$data['userStatus'] ?? null, $data['userStatus'] ?? null,
); );
} }
public function jsonSerialize(): mixed { public function jsonSerialize(): mixed {
return [ return [
'id' => $this->id, 'id' => $this->id,
'username' => $this->username, 'username' => $this->username,
'firstName' => $this->firstName, 'firstName' => $this->firstName,
'lastName' => $this->lastName, 'lastName' => $this->lastName,
'email' => $this->email, 'email' => $this->email,
'password' => $this->password, 'password' => $this->password,
'phone' => $this->phone, 'phone' => $this->phone,
'userStatus' => $this->userStatus, 'userStatus' => $this->userStatus,
]; ];
} }
} }

View File

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