From 4222ae16e7848e0b3f062a9a989d387de307a7af Mon Sep 17 00:00:00 2001 From: Alex Dowad Date: Mon, 11 May 2020 20:32:13 +0200 Subject: SplFixedArray is Aggregate, not Iterable One strange feature of SplFixedArray was that it could not be used in nested foreach loops. If one did so, the inner loop would overwrite the iteration state of the outer loop. To illustrate: $spl = SplFixedArray::fromArray([0, 1]); foreach ($spl as $a) { foreach ($spl as $b) { echo "$a $b"; } } Would only print two lines: 0 0 0 1 Use the new InternalIterator feature which was introduced in ff19ec2df3 to convert SplFixedArray to an Aggregate rather than Iterable. As a bonus, we get to trim down some ugly code! Yay! --- UPGRADING | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'UPGRADING') diff --git a/UPGRADING b/UPGRADING index aaebf52de9..a0aa20841f 100644 --- a/UPGRADING +++ b/UPGRADING @@ -502,6 +502,12 @@ PHP 8.0 UPGRADE NOTES . spl_autoload_register() will now always throw a TypeError on invalid arguments, therefore the second argument $do_throw is ignored and a notice will be emitted if it is set to false. + . SplFixedArray is now an IteratorAggregate and not an Iterator. + SplFixedArray::rewind(), ::current(), ::key(), ::next(), and ::valid() + have been removed. In their place, SplFixedArray::getIterator() has been + added. Any code which uses explicit iteration over SplFixedArray must now + obtain an Iterator through SplFixedArray::getIterator(). This means that + SplFixedArray is now safe to use in nested loops. - Standard: . assert() will no longer evaluate string arguments, instead they will be -- cgit v1.2.1