Bug #72051 [Opn->Csd]: The reference in CallbackFilterIterator doesn't work as expected
| From: | laruence@php.net | Date: | Tue, 19 Apr 2016 03:04:07 +0000 |
| Subject: | Bug #72051 [Opn->Csd]: The reference in CallbackFilterIterator doesn't work as expected | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-200642@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72051&edit=1
ID: 72051
Updated by: laruence@php.net
Reported by: oparkhomenko at magecore dot com
Summary: The reference in CallbackFilterIterator doesn't work
as expected
-Status: Open
+Status: Closed
Type: Bug
Package: SPL related
Operating System: Irrelevant
PHP Version: 7.0.5
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7648f20de3ea31a4ee720238149af8018c0f908f
Log: Fixed bug #72051 (The reference in CallbackFilterIterator doesn't work as expected)
Previous Comments:
------------------------------------------------------------------------
[2016-04-18 17:18:53] oparkhomenko at magecore dot com
Description:
------------
When we use reference on the object property instead of value in callback function of
CallbackFilterIterator we expect that we can change this property value inside of the function, but
in php 7 this functionality doesn't work.
Test script:
---------------
<?php
$data = [
[1,2]
];
$callbackTest = new CallbackFilterIterator(new ArrayIterator($data), function (&$current) {
$current['message'] = 'Test message';
return true;
});
$callbackTest->rewind();
$data = $callbackTest->current();
$callbackTest->next();
var_dump($data);
Expected result:
----------------
array(3) {
[0]=>
int(1)
[1]=>
int(2)
["message"]=>
string(12) "Test message"
}
Actual result:
--------------
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72051&edit=1