http_build_query() skips Stringable params
Offen
Bug
Extension: standard
Status: Verified
- Vorherrschende Sprache
- C
- Sterne
- 40.4k
- Forks
- 8.1k
- Ø Merge
- 2 T. 13 Std.
- Gemergte PRs (30 T.)
- 96
Beschreibung
Description
The following code:
<?php
$params = [
'param1' => 1,
'param2' => new Class {
public function __toString():string {return 'test';}
}
];
echo http_build_query($params);
foreach ($params as $k => &$v) $params[$k] = (string) $v;
echo http_build_query($params);
Resulted in this output:
param1=1
But I expected this output instead:
param1=1¶m2=test
... as __toString() should have been implicitly called on the object. The ugly manual conversion shouldn't be necessary.
PHP Version
PHP 8.1
Operating System
Any
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Bewertung
Dieses Issue wurde noch nicht bewertet.