]> granicus.if.org Git - php/commitdiff
Don't allow separation in CallbackFilterIterator
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 7 Jul 2020 07:04:20 +0000 (09:04 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 7 Jul 2020 07:04:20 +0000 (09:04 +0200)
As the name might suggest, this is a *filter* iterator. If you want
to have a *map* iterator, write one, or use a generator.

ext/spl/spl_iterators.c
ext/spl/tests/bug72051.phpt

index 1656ef1f77d0a3189b5ce370ae1b05f97d44ae19..9e4ed5036f98b5631e3cc1acad4e17a914d08b7e 100644 (file)
@@ -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;
@@ -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]);
 }
 /* }}} */
 
index b0fe05169ab1e63f7d81d514c3092d9d2aa325b1..42cc1ea8330c484da19d885278021927f8447c55 100644 (file)
@@ -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
 )