Skip to content

Commit 9a92cd5

Browse files
committed
Cast to int in HeaderSelector::getNextWeight()
1 parent 4a7e0c9 commit 9a92cd5

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

modules/openapi-generator/src/main/resources/php-nextgen/HeaderSelector.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ class HeaderSelector
157157

158158
/**
159159
* @param array[] $headers
160-
* @param float $currentWeight
160+
* @param int $currentWeight
161161
* @param bool $hasMoreThan28Headers
162162
* @return string[] array of adjusted "Accept" headers
163163
*/
164-
private function adjustWeight(array $headers, float &$currentWeight, bool $hasMoreThan28Headers): array
164+
private function adjustWeight(array $headers, int &$currentWeight, bool $hasMoreThan28Headers): array
165165
{
166166
usort($headers, function (array $a, array $b) {
167167
return $b['weight'] - $a['weight'];
@@ -230,6 +230,6 @@ class HeaderSelector
230230
return $currentWeight - 1;
231231
}
232232

233-
return $currentWeight - 10 ** floor( log10($currentWeight - 1) );
233+
return (int) ($currentWeight - 10 ** floor( log10($currentWeight - 1) ));
234234
}
235235
}

samples/client/echo_api/php-nextgen-streaming/src/HeaderSelector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ private function getHeaderAndWeight(string $header): array
166166

167167
/**
168168
* @param array[] $headers
169-
* @param float $currentWeight
169+
* @param int $currentWeight
170170
* @param bool $hasMoreThan28Headers
171171
* @return string[] array of adjusted "Accept" headers
172172
*/
173-
private function adjustWeight(array $headers, float &$currentWeight, bool $hasMoreThan28Headers): array
173+
private function adjustWeight(array $headers, int &$currentWeight, bool $hasMoreThan28Headers): array
174174
{
175175
usort($headers, function (array $a, array $b) {
176176
return $b['weight'] - $a['weight'];
@@ -239,6 +239,6 @@ public function getNextWeight(int $currentWeight, bool $hasMoreThan28Headers): i
239239
return $currentWeight - 1;
240240
}
241241

242-
return $currentWeight - 10 ** floor( log10($currentWeight - 1) );
242+
return (int) ($currentWeight - 10 ** floor( log10($currentWeight - 1) ));
243243
}
244244
}

samples/client/echo_api/php-nextgen/src/HeaderSelector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ private function getHeaderAndWeight(string $header): array
166166

167167
/**
168168
* @param array[] $headers
169-
* @param float $currentWeight
169+
* @param int $currentWeight
170170
* @param bool $hasMoreThan28Headers
171171
* @return string[] array of adjusted "Accept" headers
172172
*/
173-
private function adjustWeight(array $headers, float &$currentWeight, bool $hasMoreThan28Headers): array
173+
private function adjustWeight(array $headers, int &$currentWeight, bool $hasMoreThan28Headers): array
174174
{
175175
usort($headers, function (array $a, array $b) {
176176
return $b['weight'] - $a['weight'];
@@ -239,6 +239,6 @@ public function getNextWeight(int $currentWeight, bool $hasMoreThan28Headers): i
239239
return $currentWeight - 1;
240240
}
241241

242-
return $currentWeight - 10 ** floor( log10($currentWeight - 1) );
242+
return (int) ($currentWeight - 10 ** floor( log10($currentWeight - 1) ));
243243
}
244244
}

samples/client/petstore/php-nextgen/OpenAPIClient-php/src/HeaderSelector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ private function getHeaderAndWeight(string $header): array
165165

166166
/**
167167
* @param array[] $headers
168-
* @param float $currentWeight
168+
* @param int $currentWeight
169169
* @param bool $hasMoreThan28Headers
170170
* @return string[] array of adjusted "Accept" headers
171171
*/
172-
private function adjustWeight(array $headers, float &$currentWeight, bool $hasMoreThan28Headers): array
172+
private function adjustWeight(array $headers, int &$currentWeight, bool $hasMoreThan28Headers): array
173173
{
174174
usort($headers, function (array $a, array $b) {
175175
return $b['weight'] - $a['weight'];
@@ -238,6 +238,6 @@ public function getNextWeight(int $currentWeight, bool $hasMoreThan28Headers): i
238238
return $currentWeight - 1;
239239
}
240240

241-
return $currentWeight - 10 ** floor( log10($currentWeight - 1) );
241+
return (int) ($currentWeight - 10 ** floor( log10($currentWeight - 1) ));
242242
}
243243
}

0 commit comments

Comments
 (0)