From 0338bde8fd84e714d8db77e086befb440e600d9d Mon Sep 17 00:00:00 2001 From: Wouter Bohlken Date: Mon, 24 Nov 2025 14:58:46 +0100 Subject: [PATCH] Cast to int in HeaderSelector::getNextWeight() --- .../resources/php-nextgen/HeaderSelector.mustache | 14 +++++++------- .../php-nextgen-streaming/src/HeaderSelector.php | 14 +++++++------- .../echo_api/php-nextgen/src/HeaderSelector.php | 14 +++++++------- .../OpenAPIClient-php/src/HeaderSelector.php | 14 +++++++------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/php-nextgen/HeaderSelector.mustache b/modules/openapi-generator/src/main/resources/php-nextgen/HeaderSelector.mustache index c0fc8f599083..ebe71cbf7a5b 100644 --- a/modules/openapi-generator/src/main/resources/php-nextgen/HeaderSelector.mustache +++ b/modules/openapi-generator/src/main/resources/php-nextgen/HeaderSelector.mustache @@ -186,12 +186,12 @@ class HeaderSelector /** * @param string $header - * @param int $weight + * @param float $weight * @return string */ - private function buildAcceptHeader(string $header, int $weight): string + private function buildAcceptHeader(string $header, float $weight): string { - if($weight === 1000) { + if ($weight === 1000.0) { return $header; } @@ -216,11 +216,11 @@ class HeaderSelector * if there is a maximum of 28 "Accept" headers. If we have more than that (which is extremely unlikely), then we fall back to a 1-by-1 * decrement rule, which will result in quality codes like "q=0.999", "q=0.998" etc. * - * @param int $currentWeight varying from 1 to 1000 (will be divided by 1000 to build the quality value) - * @param bool $hasMoreThan28Headers - * @return int + * @param float $currentWeight varying from 1 to 1000 (will be divided by 1000 to build the quality value) + * @param bool $hasMoreThan28Headers + * @return float */ - public function getNextWeight(int $currentWeight, bool $hasMoreThan28Headers): int + public function getNextWeight(float $currentWeight, bool $hasMoreThan28Headers): float { if ($currentWeight <= 1) { return 1; diff --git a/samples/client/echo_api/php-nextgen-streaming/src/HeaderSelector.php b/samples/client/echo_api/php-nextgen-streaming/src/HeaderSelector.php index a1a236c835e3..1f58a0214b62 100644 --- a/samples/client/echo_api/php-nextgen-streaming/src/HeaderSelector.php +++ b/samples/client/echo_api/php-nextgen-streaming/src/HeaderSelector.php @@ -195,12 +195,12 @@ private function adjustWeight(array $headers, float &$currentWeight, bool $hasMo /** * @param string $header - * @param int $weight + * @param float $weight * @return string */ - private function buildAcceptHeader(string $header, int $weight): string + private function buildAcceptHeader(string $header, float $weight): string { - if($weight === 1000) { + if ($weight === 1000.0) { return $header; } @@ -225,11 +225,11 @@ private function buildAcceptHeader(string $header, int $weight): string * if there is a maximum of 28 "Accept" headers. If we have more than that (which is extremely unlikely), then we fall back to a 1-by-1 * decrement rule, which will result in quality codes like "q=0.999", "q=0.998" etc. * - * @param int $currentWeight varying from 1 to 1000 (will be divided by 1000 to build the quality value) - * @param bool $hasMoreThan28Headers - * @return int + * @param float $currentWeight varying from 1 to 1000 (will be divided by 1000 to build the quality value) + * @param bool $hasMoreThan28Headers + * @return float */ - public function getNextWeight(int $currentWeight, bool $hasMoreThan28Headers): int + public function getNextWeight(float $currentWeight, bool $hasMoreThan28Headers): float { if ($currentWeight <= 1) { return 1; diff --git a/samples/client/echo_api/php-nextgen/src/HeaderSelector.php b/samples/client/echo_api/php-nextgen/src/HeaderSelector.php index a1a236c835e3..1f58a0214b62 100644 --- a/samples/client/echo_api/php-nextgen/src/HeaderSelector.php +++ b/samples/client/echo_api/php-nextgen/src/HeaderSelector.php @@ -195,12 +195,12 @@ private function adjustWeight(array $headers, float &$currentWeight, bool $hasMo /** * @param string $header - * @param int $weight + * @param float $weight * @return string */ - private function buildAcceptHeader(string $header, int $weight): string + private function buildAcceptHeader(string $header, float $weight): string { - if($weight === 1000) { + if ($weight === 1000.0) { return $header; } @@ -225,11 +225,11 @@ private function buildAcceptHeader(string $header, int $weight): string * if there is a maximum of 28 "Accept" headers. If we have more than that (which is extremely unlikely), then we fall back to a 1-by-1 * decrement rule, which will result in quality codes like "q=0.999", "q=0.998" etc. * - * @param int $currentWeight varying from 1 to 1000 (will be divided by 1000 to build the quality value) - * @param bool $hasMoreThan28Headers - * @return int + * @param float $currentWeight varying from 1 to 1000 (will be divided by 1000 to build the quality value) + * @param bool $hasMoreThan28Headers + * @return float */ - public function getNextWeight(int $currentWeight, bool $hasMoreThan28Headers): int + public function getNextWeight(float $currentWeight, bool $hasMoreThan28Headers): float { if ($currentWeight <= 1) { return 1; diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/HeaderSelector.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/HeaderSelector.php index 0f7061c6840f..50f56032c20b 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/HeaderSelector.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/HeaderSelector.php @@ -194,12 +194,12 @@ private function adjustWeight(array $headers, float &$currentWeight, bool $hasMo /** * @param string $header - * @param int $weight + * @param float $weight * @return string */ - private function buildAcceptHeader(string $header, int $weight): string + private function buildAcceptHeader(string $header, float $weight): string { - if($weight === 1000) { + if ($weight === 1000.0) { return $header; } @@ -224,11 +224,11 @@ private function buildAcceptHeader(string $header, int $weight): string * if there is a maximum of 28 "Accept" headers. If we have more than that (which is extremely unlikely), then we fall back to a 1-by-1 * decrement rule, which will result in quality codes like "q=0.999", "q=0.998" etc. * - * @param int $currentWeight varying from 1 to 1000 (will be divided by 1000 to build the quality value) - * @param bool $hasMoreThan28Headers - * @return int + * @param float $currentWeight varying from 1 to 1000 (will be divided by 1000 to build the quality value) + * @param bool $hasMoreThan28Headers + * @return float */ - public function getNextWeight(int $currentWeight, bool $hasMoreThan28Headers): int + public function getNextWeight(float $currentWeight, bool $hasMoreThan28Headers): float { if ($currentWeight <= 1) { return 1;