Doc #81508 [Opn]: http_build_query returns empty string given ArrayIterator as input

From: Date: Tue, 05 Oct 2021 19:01:13 +0000
Subject: Doc #81508 [Opn]: http_build_query returns empty string given ArrayIterator as input
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-19252@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81508&edit=1 ID: 81508 Updated by: requinix@php.net Reported by: mintobit at gmail dot com Summary: http_build_query returns empty string given ArrayIterator as input Status: Open Type: Documentation Problem Package: URL related Operating System: Linux PHP Version: 7.4.24 Block user comment: N Private report: N New Comment: Ah, yup, that is exactly what it says. My brain likes to bundle them together. Presumably it's the same underlying change affecting both. Previous Comments: ------------------------------------------------------------------------ [2021-10-05 18:33:36] salathe@php.net > Calling get_object_vars() on an ArrayObject instance will now ... The quoted section from the migration guide references ArrayObject, but makes no mention that the change also applies to ArrayIterator. ------------------------------------------------------------------------ [2021-10-05 16:00:28] requinix@php.net > Calling get_object_vars() on an ArrayObject instance will now always return the > properties of the ArrayObject itself (or a subclass). Previously it returned the > values of the wrapped array/object unless the ArrayObject::STD_PROP_LIST flag > was specified. > > Other affected operations are: > > * ReflectionObject::getProperties() > * reset(), current(), etc. Use Iterator methods instead. > * Potentially others working on object properties as a list, e.g. array_walk(). The third bullet point is the one that affects http_build_query(). ------------------------------------------------------------------------ [2021-10-05 15:28:03] mintobit at gmail dot com Description: ------------ Have not found anything related here https://www.php.net/manual/en/migration74.incompatible.php. Would appreciate if somebody can explain why this happened: wondering if this is expected and should be documented. Test script: --------------- <?php $array = [ ['ids' => [1,2,3,4]], ['key' => 1] ]; var_dump(http_build_query(new ArrayIterator($array))); Expected result: ---------------- string(92) "0%5Bids%5D%5B0%5D=1&0%5Bids%5D%5B1%5D=2&0%5Bids%5D%5B2%5D=3&0%5Bids%5D%5B3%5D=4&1%5Bkey%5D=1" Actual result: -------------- string(0) "" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81508&edit=1

« previous php.doc.bugs (#19252) next »