[php-src] Issue #7952: `CallbackFilterIterator` is not rewind/initialized

From: Date: Sun, 16 Jan 2022 20:32:28 +0000
Subject: [php-src] Issue #7952: `CallbackFilterIterator` is not rewind/initialized
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-239040@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/7952 Author: mvorisek ### Description The following code: ```php <?php $data = []; $data['x'] = ['x_v']; $data['y'] = ['y_v']; $gen = new \ArrayIterator($data); var_dump($gen->valid()); var_dump($gen->current()); $filterFx = function ($row) { return count($row) !== false; // always true }; $genOrig = $gen; $gen = new \CallbackFilterIterator($gen, $filterFx); $genOrig->next(); // has correctly no effect // $gen->rewind(); // must be called, iterator is not initialized by default var_dump($gen->valid()); var_dump($gen->current()); var_dump($gen->valid()); var_dump($gen->next()); ``` Resulted in this output: ``` bool(true) array(1) { [0]=> string(3) "x_v" } bool(false) NULL bool(false) NULL ``` demo https://3v4l.org/trdBX But I expected this output instead: ``` bool(true) array(1) { [0]=> string(3) "x_v" } bool(true) array(1) { [0]=> string(3) "x_v" } bool(true) NULL ``` ### PHP Version 8.0 ### Operating System any

« previous php.bugs (#239040) next »