Skip to content

Commit 6a37393

Browse files
Deprecate non-finite float values (#788)
1 parent 640e289 commit 6a37393

4 files changed

Lines changed: 24 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 2.12.0 - Upcoming
9+
10+
### Deprecated
11+
12+
- Deprecated non-finite float values that guzzlehttp/psr7 3.0 will reject
13+
814
## 2.11.1 - 2026-06-12
915

1016
### Fixed

src/Query.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ public static function build(array $params, $encoding = PHP_QUERY_RFC3986, bool
127127
private static function normalizeNonFiniteFloat($value)
128128
{
129129
if (is_float($value) && !is_finite($value)) {
130+
\trigger_deprecation(
131+
'guzzlehttp/psr7',
132+
'2.12',
133+
'Passing a non-finite float to Query::build() is deprecated; guzzlehttp/psr7 3.0 rejects non-finite floats.'
134+
);
135+
130136
return is_nan($value) ? 'NAN' : ($value > 0 ? 'INF' : '-INF');
131137
}
132138

src/Uri.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,12 @@ public static function withQueryValues(UriInterface $uri, array $keyValueArray):
386386
private static function stringifyQueryValue($value): string
387387
{
388388
if (is_float($value) && !is_finite($value)) {
389+
\trigger_deprecation(
390+
'guzzlehttp/psr7',
391+
'2.12',
392+
'Passing a non-finite float to Uri::withQueryValues() is deprecated; guzzlehttp/psr7 3.0 rejects non-finite floats.'
393+
);
394+
389395
return is_nan($value) ? 'NAN' : ($value > 0 ? 'INF' : '-INF');
390396
}
391397

src/Utils.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,12 @@ public static function streamFor($resource = '', array $options = []): StreamInt
473473
// Convert non-finite floats explicitly, as implicit coercion of
474474
// NAN emits a warning on PHP 8.5.
475475
if (is_float($resource) && !is_finite($resource)) {
476+
\trigger_deprecation(
477+
'guzzlehttp/psr7',
478+
'2.12',
479+
'Passing a non-finite float to Utils::streamFor() is deprecated; guzzlehttp/psr7 3.0 rejects non-finite floats.'
480+
);
481+
476482
$resource = is_nan($resource) ? 'NAN' : ($resource > 0 ? 'INF' : '-INF');
477483
}
478484

0 commit comments

Comments
 (0)