From d534d4fc32c2988887d41ca482382f2719a74441 Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Mon, 28 Apr 2025 10:00:29 +0200 Subject: [PATCH] fix(php-nextgen): do not call static methods dynamically --- .../resources/php-nextgen/model_generic.mustache | 4 ++-- .../src/Model/DefaultValue.php | 2 +- .../php-nextgen-streaming/src/Model/Pet.php | 4 ++-- .../php-nextgen-streaming/src/Model/Query.php | 2 +- .../php-nextgen/src/Model/DefaultValue.php | 2 +- .../echo_api/php-nextgen/src/Model/Pet.php | 4 ++-- .../echo_api/php-nextgen/src/Model/Query.php | 2 +- .../OpenAPIClient-php/src/Model/EnumArrays.php | 6 +++--- .../OpenAPIClient-php/src/Model/EnumTest.php | 16 ++++++++-------- .../OpenAPIClient-php/src/Model/MapTest.php | 2 +- .../OpenAPIClient-php/src/Model/Order.php | 4 ++-- .../src/Model/ParentWithNullable.php | 4 ++-- .../OpenAPIClient-php/src/Model/Pet.php | 4 ++-- 13 files changed, 28 insertions(+), 28 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/php-nextgen/model_generic.mustache b/modules/openapi-generator/src/main/resources/php-nextgen/model_generic.mustache index ce2670ef0fd3..a08517fc7609 100644 --- a/modules/openapi-generator/src/main/resources/php-nextgen/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/php-nextgen/model_generic.mustache @@ -301,7 +301,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}}{{/parentSchema}}{{^par {{/required}} {{#isEnum}} {{^isContainer}} - $allowedValues = $this->{{getter}}AllowableValues(); + $allowedValues = self::{{getter}}AllowableValues(); if (!is_null($this->container['{{name}}']) && !in_array($this->container['{{name}}'], $allowedValues, true)) { $invalidProperties[] = sprintf( "invalid value '%s' for '{{name}}', must be one of '%s'", @@ -416,7 +416,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}}{{/parentSchema}}{{^par } {{/isNullable}} {{#isEnum}} - $allowedValues = $this->{{getter}}AllowableValues(); + $allowedValues = self::{{getter}}AllowableValues(); {{^isContainer}} if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}!in_array(${{{name}}}, $allowedValues, true)) { {{#enumUnknownDefaultCase}} diff --git a/samples/client/echo_api/php-nextgen-streaming/src/Model/DefaultValue.php b/samples/client/echo_api/php-nextgen-streaming/src/Model/DefaultValue.php index cab197e2a346..eda2596ba179 100644 --- a/samples/client/echo_api/php-nextgen-streaming/src/Model/DefaultValue.php +++ b/samples/client/echo_api/php-nextgen-streaming/src/Model/DefaultValue.php @@ -404,7 +404,7 @@ public function setArrayStringEnumDefault(?array $array_string_enum_default): st if (is_null($array_string_enum_default)) { throw new InvalidArgumentException('non-nullable array_string_enum_default cannot be null'); } - $allowedValues = $this->getArrayStringEnumDefaultAllowableValues(); + $allowedValues = self::getArrayStringEnumDefaultAllowableValues(); if (array_diff($array_string_enum_default, $allowedValues)) { throw new InvalidArgumentException( sprintf( diff --git a/samples/client/echo_api/php-nextgen-streaming/src/Model/Pet.php b/samples/client/echo_api/php-nextgen-streaming/src/Model/Pet.php index 42fc9646d584..65875bb3d79c 100644 --- a/samples/client/echo_api/php-nextgen-streaming/src/Model/Pet.php +++ b/samples/client/echo_api/php-nextgen-streaming/src/Model/Pet.php @@ -331,7 +331,7 @@ public function listInvalidProperties(): array if ($this->container['photo_urls'] === null) { $invalidProperties[] = "'photo_urls' can't be null"; } - $allowedValues = $this->getStatusAllowableValues(); + $allowedValues = self::getStatusAllowableValues(); if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { $invalidProperties[] = sprintf( "invalid value '%s' for 'status', must be one of '%s'", @@ -512,7 +512,7 @@ public function setStatus(?string $status): static if (is_null($status)) { throw new InvalidArgumentException('non-nullable status cannot be null'); } - $allowedValues = $this->getStatusAllowableValues(); + $allowedValues = self::getStatusAllowableValues(); if (!in_array($status, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( diff --git a/samples/client/echo_api/php-nextgen-streaming/src/Model/Query.php b/samples/client/echo_api/php-nextgen-streaming/src/Model/Query.php index 88d5249f6ca2..6873415b3322 100644 --- a/samples/client/echo_api/php-nextgen-streaming/src/Model/Query.php +++ b/samples/client/echo_api/php-nextgen-streaming/src/Model/Query.php @@ -361,7 +361,7 @@ public function setOutcomes(?array $outcomes): static if (is_null($outcomes)) { throw new InvalidArgumentException('non-nullable outcomes cannot be null'); } - $allowedValues = $this->getOutcomesAllowableValues(); + $allowedValues = self::getOutcomesAllowableValues(); if (array_diff($outcomes, $allowedValues)) { throw new InvalidArgumentException( sprintf( diff --git a/samples/client/echo_api/php-nextgen/src/Model/DefaultValue.php b/samples/client/echo_api/php-nextgen/src/Model/DefaultValue.php index cab197e2a346..eda2596ba179 100644 --- a/samples/client/echo_api/php-nextgen/src/Model/DefaultValue.php +++ b/samples/client/echo_api/php-nextgen/src/Model/DefaultValue.php @@ -404,7 +404,7 @@ public function setArrayStringEnumDefault(?array $array_string_enum_default): st if (is_null($array_string_enum_default)) { throw new InvalidArgumentException('non-nullable array_string_enum_default cannot be null'); } - $allowedValues = $this->getArrayStringEnumDefaultAllowableValues(); + $allowedValues = self::getArrayStringEnumDefaultAllowableValues(); if (array_diff($array_string_enum_default, $allowedValues)) { throw new InvalidArgumentException( sprintf( diff --git a/samples/client/echo_api/php-nextgen/src/Model/Pet.php b/samples/client/echo_api/php-nextgen/src/Model/Pet.php index 42fc9646d584..65875bb3d79c 100644 --- a/samples/client/echo_api/php-nextgen/src/Model/Pet.php +++ b/samples/client/echo_api/php-nextgen/src/Model/Pet.php @@ -331,7 +331,7 @@ public function listInvalidProperties(): array if ($this->container['photo_urls'] === null) { $invalidProperties[] = "'photo_urls' can't be null"; } - $allowedValues = $this->getStatusAllowableValues(); + $allowedValues = self::getStatusAllowableValues(); if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { $invalidProperties[] = sprintf( "invalid value '%s' for 'status', must be one of '%s'", @@ -512,7 +512,7 @@ public function setStatus(?string $status): static if (is_null($status)) { throw new InvalidArgumentException('non-nullable status cannot be null'); } - $allowedValues = $this->getStatusAllowableValues(); + $allowedValues = self::getStatusAllowableValues(); if (!in_array($status, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( diff --git a/samples/client/echo_api/php-nextgen/src/Model/Query.php b/samples/client/echo_api/php-nextgen/src/Model/Query.php index 88d5249f6ca2..6873415b3322 100644 --- a/samples/client/echo_api/php-nextgen/src/Model/Query.php +++ b/samples/client/echo_api/php-nextgen/src/Model/Query.php @@ -361,7 +361,7 @@ public function setOutcomes(?array $outcomes): static if (is_null($outcomes)) { throw new InvalidArgumentException('non-nullable outcomes cannot be null'); } - $allowedValues = $this->getOutcomesAllowableValues(); + $allowedValues = self::getOutcomesAllowableValues(); if (array_diff($outcomes, $allowedValues)) { throw new InvalidArgumentException( sprintf( diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/EnumArrays.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/EnumArrays.php index 70c670f3cbae..fa3c249b4c33 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/EnumArrays.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/EnumArrays.php @@ -309,7 +309,7 @@ public function listInvalidProperties(): array { $invalidProperties = []; - $allowedValues = $this->getJustSymbolAllowableValues(); + $allowedValues = self::getJustSymbolAllowableValues(); if (!is_null($this->container['just_symbol']) && !in_array($this->container['just_symbol'], $allowedValues, true)) { $invalidProperties[] = sprintf( "invalid value '%s' for 'just_symbol', must be one of '%s'", @@ -355,7 +355,7 @@ public function setJustSymbol(?string $just_symbol): static if (is_null($just_symbol)) { throw new InvalidArgumentException('non-nullable just_symbol cannot be null'); } - $allowedValues = $this->getJustSymbolAllowableValues(); + $allowedValues = self::getJustSymbolAllowableValues(); if (!in_array($just_symbol, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( @@ -392,7 +392,7 @@ public function setArrayEnum(?array $array_enum): static if (is_null($array_enum)) { throw new InvalidArgumentException('non-nullable array_enum cannot be null'); } - $allowedValues = $this->getArrayEnumAllowableValues(); + $allowedValues = self::getArrayEnumAllowableValues(); if (array_diff($array_enum, $allowedValues)) { throw new InvalidArgumentException( sprintf( diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/EnumTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/EnumTest.php index 2df07270eb81..a2aa96554e0d 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/EnumTest.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/EnumTest.php @@ -385,7 +385,7 @@ public function listInvalidProperties(): array { $invalidProperties = []; - $allowedValues = $this->getEnumStringAllowableValues(); + $allowedValues = self::getEnumStringAllowableValues(); if (!is_null($this->container['enum_string']) && !in_array($this->container['enum_string'], $allowedValues, true)) { $invalidProperties[] = sprintf( "invalid value '%s' for 'enum_string', must be one of '%s'", @@ -397,7 +397,7 @@ public function listInvalidProperties(): array if ($this->container['enum_string_required'] === null) { $invalidProperties[] = "'enum_string_required' can't be null"; } - $allowedValues = $this->getEnumStringRequiredAllowableValues(); + $allowedValues = self::getEnumStringRequiredAllowableValues(); if (!is_null($this->container['enum_string_required']) && !in_array($this->container['enum_string_required'], $allowedValues, true)) { $invalidProperties[] = sprintf( "invalid value '%s' for 'enum_string_required', must be one of '%s'", @@ -406,7 +406,7 @@ public function listInvalidProperties(): array ); } - $allowedValues = $this->getEnumIntegerAllowableValues(); + $allowedValues = self::getEnumIntegerAllowableValues(); if (!is_null($this->container['enum_integer']) && !in_array($this->container['enum_integer'], $allowedValues, true)) { $invalidProperties[] = sprintf( "invalid value '%s' for 'enum_integer', must be one of '%s'", @@ -415,7 +415,7 @@ public function listInvalidProperties(): array ); } - $allowedValues = $this->getEnumNumberAllowableValues(); + $allowedValues = self::getEnumNumberAllowableValues(); if (!is_null($this->container['enum_number']) && !in_array($this->container['enum_number'], $allowedValues, true)) { $invalidProperties[] = sprintf( "invalid value '%s' for 'enum_number', must be one of '%s'", @@ -461,7 +461,7 @@ public function setEnumString(?string $enum_string): static if (is_null($enum_string)) { throw new InvalidArgumentException('non-nullable enum_string cannot be null'); } - $allowedValues = $this->getEnumStringAllowableValues(); + $allowedValues = self::getEnumStringAllowableValues(); if (!in_array($enum_string, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( @@ -498,7 +498,7 @@ public function setEnumStringRequired(string $enum_string_required): static if (is_null($enum_string_required)) { throw new InvalidArgumentException('non-nullable enum_string_required cannot be null'); } - $allowedValues = $this->getEnumStringRequiredAllowableValues(); + $allowedValues = self::getEnumStringRequiredAllowableValues(); if (!in_array($enum_string_required, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( @@ -535,7 +535,7 @@ public function setEnumInteger(?int $enum_integer): static if (is_null($enum_integer)) { throw new InvalidArgumentException('non-nullable enum_integer cannot be null'); } - $allowedValues = $this->getEnumIntegerAllowableValues(); + $allowedValues = self::getEnumIntegerAllowableValues(); if (!in_array($enum_integer, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( @@ -572,7 +572,7 @@ public function setEnumNumber(?float $enum_number): static if (is_null($enum_number)) { throw new InvalidArgumentException('non-nullable enum_number cannot be null'); } - $allowedValues = $this->getEnumNumberAllowableValues(); + $allowedValues = self::getEnumNumberAllowableValues(); if (!in_array($enum_number, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/MapTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/MapTest.php index 9147f19bdfe6..9591024e182e 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/MapTest.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/MapTest.php @@ -372,7 +372,7 @@ public function setMapOfEnumString(?array $map_of_enum_string): static if (is_null($map_of_enum_string)) { throw new InvalidArgumentException('non-nullable map_of_enum_string cannot be null'); } - $allowedValues = $this->getMapOfEnumStringAllowableValues(); + $allowedValues = self::getMapOfEnumStringAllowableValues(); if (array_diff($map_of_enum_string, $allowedValues)) { throw new InvalidArgumentException( sprintf( diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/Order.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/Order.php index 4d22d043e4d8..6426194d90b9 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/Order.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/Order.php @@ -324,7 +324,7 @@ public function listInvalidProperties(): array { $invalidProperties = []; - $allowedValues = $this->getStatusAllowableValues(); + $allowedValues = self::getStatusAllowableValues(); if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { $invalidProperties[] = sprintf( "invalid value '%s' for 'status', must be one of '%s'", @@ -478,7 +478,7 @@ public function setStatus(?string $status): static if (is_null($status)) { throw new InvalidArgumentException('non-nullable status cannot be null'); } - $allowedValues = $this->getStatusAllowableValues(); + $allowedValues = self::getStatusAllowableValues(); if (!in_array($status, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ParentWithNullable.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ParentWithNullable.php index a10b7ad027fe..cbc573792711 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ParentWithNullable.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ParentWithNullable.php @@ -295,7 +295,7 @@ public function listInvalidProperties(): array { $invalidProperties = []; - $allowedValues = $this->getTypeAllowableValues(); + $allowedValues = self::getTypeAllowableValues(); if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { $invalidProperties[] = sprintf( "invalid value '%s' for 'type', must be one of '%s'", @@ -341,7 +341,7 @@ public function setType(?string $type): static if (is_null($type)) { throw new InvalidArgumentException('non-nullable type cannot be null'); } - $allowedValues = $this->getTypeAllowableValues(); + $allowedValues = self::getTypeAllowableValues(); if (!in_array($type, $allowedValues, true)) { throw new InvalidArgumentException( sprintf( diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/Pet.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/Pet.php index 0a3a64d17290..a5d9e8eefa73 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/Pet.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/Pet.php @@ -330,7 +330,7 @@ public function listInvalidProperties(): array if ($this->container['photo_urls'] === null) { $invalidProperties[] = "'photo_urls' can't be null"; } - $allowedValues = $this->getStatusAllowableValues(); + $allowedValues = self::getStatusAllowableValues(); if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { $invalidProperties[] = sprintf( "invalid value '%s' for 'status', must be one of '%s'", @@ -513,7 +513,7 @@ public function setStatus(?string $status): static if (is_null($status)) { throw new InvalidArgumentException('non-nullable status cannot be null'); } - $allowedValues = $this->getStatusAllowableValues(); + $allowedValues = self::getStatusAllowableValues(); if (!in_array($status, $allowedValues, true)) { throw new InvalidArgumentException( sprintf(