]> granicus.if.org Git - php/commitdiff
Test for non-string replacement, bug#54304
authorHannes Magnusson <bjori@php.net>
Mon, 12 Sep 2011 17:20:44 +0000 (17:20 +0000)
committerHannes Magnusson <bjori@php.net>
Mon, 12 Sep 2011 17:20:44 +0000 (17:20 +0000)
ext/spl/tests/bug54304.phpt [new file with mode: 0644]

diff --git a/ext/spl/tests/bug54304.phpt b/ext/spl/tests/bug54304.phpt
new file mode 100644 (file)
index 0000000..32cbe48
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+Bug #54304 (Setting replacement value for RegexIterator doesn't work)
+--FILE--
+<?php
+class foo extends ArrayIterator {
+       public function __construct( ) {
+               parent::__construct(array(
+                       'test3'=>'test999'));
+       }
+}
+
+$h = new foo;
+$i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE);
+$i->replacement = 42;
+var_dump($i->replacement);
+foreach ($i as $name=>$value) {
+       var_dump($name, $value);
+}
+var_dump($i->replacement);
+?>
+--EXPECT--
+int(42)
+string(5) "test3"
+string(2) "42"
+int(42)
+