Skip to content

Commit

Permalink
Don't allow separation in CallbackFilterIterator
Browse files Browse the repository at this point in the history
As the name might suggest, this is a *filter* iterator. If you want
to have a *map* iterator, write one, or use a generator.
  • Loading branch information
nikic committed Jul 7, 2020
1 parent 632766a commit df8119d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions ext/spl/spl_iterators.c
Original file line number Diff line number Diff line change
Expand Up @@ -1785,7 +1785,7 @@ PHP_METHOD(CallbackFilterIterator, accept)
fci->retval = return_value;
fci->param_count = 3;
fci->params = params;
fci->no_separation = 0;
fci->no_separation = 1;

if (zend_call_function(fci, fcc) != SUCCESS || Z_ISUNDEF_P(return_value)) {
RETURN_FALSE;
Expand All @@ -1794,10 +1794,6 @@ PHP_METHOD(CallbackFilterIterator, accept)
if (EG(exception)) {
RETURN_THROWS();
}

/* zend_call_function may change args to IS_REF */
ZVAL_COPY_VALUE(&intern->current.data, &params[0]);
ZVAL_COPY_VALUE(&intern->current.key, &params[1]);
}
/* }}} */

Expand Down
4 changes: 2 additions & 2 deletions ext/spl/tests/bug72051.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ $data = $callbackTest->current();
$callbackTest->next();
print_r($data);
?>
--EXPECT--
--EXPECTF--
Warning: {closure}(): Argument #1 ($current) must be passed by reference, value given in %s on line %d
Array
(
[0] => 1
[1] => 2
[message] => Test message
)

0 comments on commit df8119d

Please sign in to comment.