]> granicus.if.org Git - php/commitdiff
Add a test for iterating SXE properties by reference
authorCraig Duncan <php@duncanc.co.uk>
Sat, 17 Feb 2018 22:38:55 +0000 (22:38 +0000)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 19 Feb 2018 20:58:57 +0000 (21:58 +0100)
ext/simplexml/tests/foreach_by_reference.phpt [new file with mode: 0644]

diff --git a/ext/simplexml/tests/foreach_by_reference.phpt b/ext/simplexml/tests/foreach_by_reference.phpt
new file mode 100644 (file)
index 0000000..070a3cf
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+SimpleXml: foreach by reference
+--SKIPIF--
+<?php if (!extension_loaded("simplexml")) print "skip"; ?>
+--FILE--
+<?php
+
+$xml = <<<XML
+<people>
+  <person>Lucy</person>
+  <person>Mikasa</person>
+</people>
+XML;
+
+$people = simplexml_load_string($xml);
+
+foreach ($people as &$person) {}
+
+?>
+--EXPECTF--
+Fatal error: Uncaught Error: An iterator cannot be used with foreach by reference in %s:%d
+Stack trace:
+#0 {main}
+  thrown in %s on line %d