diff --git a/src/Symfony/Components/Finder/Finder.php b/src/Symfony/Components/Finder/Finder.php index 2fd5099d34..4e98c81fb2 100644 --- a/src/Symfony/Components/Finder/Finder.php +++ b/src/Symfony/Components/Finder/Finder.php @@ -288,10 +288,10 @@ class Finder { if (is_array($dir)) { - $iterator = new Iterator\ChainIterator(); + $iterator = new \AppendIterator(); foreach ($dir as $d) { - $iterator->attach($this->searchInDirectory($d)); + $iterator->append($this->searchInDirectory($d)); } return $iterator; diff --git a/src/Symfony/Components/Finder/Iterator/ChainIterator.php b/src/Symfony/Components/Finder/Iterator/ChainIterator.php deleted file mode 100644 index 1ca95f7484..0000000000 --- a/src/Symfony/Components/Finder/Iterator/ChainIterator.php +++ /dev/null @@ -1,90 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * ChainIterator iterates through several iterators, one at a time. - * - * @package Symfony - * @subpackage Components_Finder - * @author Fabien Potencier - */ -class ChainIterator implements \Iterator -{ - protected $iterators; - protected $current; - protected $cursor; - - /** - * Constructor. - * - * @param Iterator[] $iterators An array of \Iterator instances - */ - public function __construct(array $iterators = array()) - { - $this->iterators = array(); - foreach ($iterators as $iterator) - { - $this->attach($iterator); - } - $this->rewind(); - } - - public function attach(\Iterator $iterator) - { - $this->iterators[] = $iterator; - } - - public function rewind() - { - $this->cursor = 0; - $this->current = 0; - foreach ($this->iterators as $iterator) - { - $iterator->rewind(); - } - } - - public function valid() - { - if ($this->current > count($this->iterators) - 1) - { - return false; - } - - // still something for the current iterator? - if ($this->iterators[$this->current]->valid()) - { - return true; - } - - // go to the next one - ++$this->current; - - return $this->valid(); - } - - public function next() - { - $this->iterators[$this->current]->next(); - } - - public function current() - { - return $this->iterators[$this->current]->current(); - } - - public function key() - { - return $this->cursor++; - } -} diff --git a/tests/Symfony/Tests/Components/Finder/Iterator/ChainIteratorTest.php b/tests/Symfony/Tests/Components/Finder/Iterator/ChainIteratorTest.php deleted file mode 100644 index 56b2da5ec0..0000000000 --- a/tests/Symfony/Tests/Components/Finder/Iterator/ChainIteratorTest.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Tests\Components\Finder\Iterator; - -use Symfony\Components\Finder\Iterator\ChainIterator; - -require_once __DIR__.'/IteratorTestCase.php'; - -class ChainIteratorTest extends IteratorTestCase -{ - public function testAccept() - { - $inner1 = new Iterator(array('test.php', 'test.py')); - $inner2 = new Iterator(array()); - $inner3 = new Iterator(array('foo.php')); - - $iterator = new ChainIterator(array($inner1, $inner2, $inner3)); - - $this->assertIterator(array('test.php', 'test.py', 'foo.php'), $iterator); - } -}