From 2327562af45b1f7d783601b69c0602ef3fbcbec7 Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Tue, 29 Apr 2025 10:29:52 +0300 Subject: [PATCH] fix(php-nextgen): do not call static methods dynamically (#21163) --- .../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 ce2670ef0fd..a08517fc760 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 cab197e2a34..eda2596ba17 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 @@ class DefaultValue implements ModelInterface, ArrayAccess, JsonSerializable 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 42fc9646d58..65875bb3d79 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 @@ class Pet implements ModelInterface, ArrayAccess, JsonSerializable 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 @@ class Pet implements ModelInterface, ArrayAccess, JsonSerializable 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 88d5249f6ca..6873415b332 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 @@ class Query implements ModelInterface, ArrayAccess, JsonSerializable 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 cab197e2a34..eda2596ba17 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 @@ class DefaultValue implements ModelInterface, ArrayAccess, JsonSerializable 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 42fc9646d58..65875bb3d79 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 @@ class Pet implements ModelInterface, ArrayAccess, JsonSerializable 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 @@ class Pet implements ModelInterface, ArrayAccess, JsonSerializable 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 88d5249f6ca..6873415b332 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 @@ class Query implements ModelInterface, ArrayAccess, JsonSerializable 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 70c670f3cba..fa3c249b4c3 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 @@ class EnumArrays implements ModelInterface, ArrayAccess, JsonSerializable { $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 @@ class EnumArrays implements ModelInterface, ArrayAccess, JsonSerializable 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 @@ class EnumArrays implements ModelInterface, ArrayAccess, JsonSerializable 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 2df07270eb8..a2aa96554e0 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 @@ class EnumTest implements ModelInterface, ArrayAccess, JsonSerializable { $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 @@ class EnumTest implements ModelInterface, ArrayAccess, JsonSerializable 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 @@ class EnumTest implements ModelInterface, ArrayAccess, JsonSerializable ); } - $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 @@ class EnumTest implements ModelInterface, ArrayAccess, JsonSerializable ); } - $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 @@ class EnumTest implements ModelInterface, ArrayAccess, JsonSerializable 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 @@ class EnumTest implements ModelInterface, ArrayAccess, JsonSerializable 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 @@ class EnumTest implements ModelInterface, ArrayAccess, JsonSerializable 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 @@ class EnumTest implements ModelInterface, ArrayAccess, JsonSerializable 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 9147f19bdfe..9591024e182 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 @@ class MapTest implements ModelInterface, ArrayAccess, JsonSerializable 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 4d22d043e4d..6426194d90b 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 @@ class Order implements ModelInterface, ArrayAccess, JsonSerializable { $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 @@ class Order implements ModelInterface, ArrayAccess, JsonSerializable 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 a10b7ad027f..cbc57379271 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 @@ class ParentWithNullable implements ModelInterface, ArrayAccess, JsonSerializabl { $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 @@ class ParentWithNullable implements ModelInterface, ArrayAccess, JsonSerializabl 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 0a3a64d1729..a5d9e8eefa7 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 @@ class Pet implements ModelInterface, ArrayAccess, JsonSerializable 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 @@ class Pet implements ModelInterface, ArrayAccess, JsonSerializable 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(