http_build_query() skips Stringable params
Aperta
Bug
Extension: standard
Status: Verified
- Lingua principale
- C
- Stelle
- 40.4k
- Fork
- 8.1k
- Merge medio
- 2g 13h
- PR unite (30g)
- 96
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Valutazione
Questa issue non è ancora stata valutata.