summaryrefslogtreecommitdiff
path: root/UPGRADING
diff options
context:
space:
mode:
authorAlex Dowad <alexinbeijing@gmail.com>2020-05-11 20:32:13 +0200
committerAlex Dowad <alexinbeijing@gmail.com>2020-09-23 08:33:24 +0200
commit4222ae16e7848e0b3f062a9a989d387de307a7af (patch)
tree049e87edb7c167065cf8399943323d4451dc69cd /UPGRADING
parent1e9db80d7264911fa4089cb7e4b3dc7f97b19c6e (diff)
downloadphp-git-4222ae16e7848e0b3f062a9a989d387de307a7af.tar.gz
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!
Diffstat (limited to 'UPGRADING')
-rw-r--r--UPGRADING6
1 files changed, 6 insertions, 0 deletions
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