1--TEST--
2SplDoublyLinkedList Iterating a DLL by reference shouldn't be permitted
3--CREDITS--
4Mark Baker mark@lange.demon.co.uk at the PHPNW2017 Conference for PHP Testfest 2017
5--FILE--
6<?php
7
8$dll = new SplDoublyLinkedList();
9
10$dll->push(2);
11$dll->push(3);
12
13try {
14    foreach($dll as $key => &$value) {
15        // We should never see this output, because the "by reference" exception should be thrown in the previous line
16        echo $value, PHP_EOL;
17        $value *= $value;
18        echo $value, PHP_EOL;
19    }
20} catch (Exception $e) {
21    echo $e->getMessage(), PHP_EOL;
22}
23
24?>
25--EXPECT--
26An iterator cannot be used with foreach by reference
27