Skip to content

Commit

Permalink
[Finder] Fixed iterator keys
Browse files Browse the repository at this point in the history
  • Loading branch information
jfsimon committed Jan 29, 2013
1 parent d16e28a commit ef593fa
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/Symfony/Component/Finder/Iterator/FilePathsIterator.php
Expand Up @@ -40,6 +40,11 @@ class FilePathsIterator extends \ArrayIterator
*/
private $subPathname;

/**
* @var SplFileInfo
*/
private $current;

/**
* @param array $paths List of paths returned by shell command
* @param string $baseDir Base dir for relative path building
Expand Down Expand Up @@ -70,21 +75,27 @@ public function __call($name, array $arguments)
*/
public function current()
{
return new SplFileInfo(parent::current(), $this->subPath, $this->subPathname);
return $this->current;
}

/**
* @return string
*/
public function key()
{
return $this->current->getPathname();
}

public function next()
{
parent::next();

$this->buildSubPath();
$this->buildProperties();
}

public function rewind()
{
parent::rewind();

$this->buildSubPath();
$this->buildProperties();
}

/**
Expand All @@ -103,7 +114,7 @@ public function getSubPathname()
return $this->subPathname;
}

private function buildSubPath()
private function buildProperties()
{
$absolutePath = parent::current();

Expand All @@ -114,5 +125,7 @@ private function buildSubPath()
} else {
$this->subPath = $this->subPathname = '';
}

$this->current = new SplFileInfo(parent::current(), $this->subPath, $this->subPathname);
}
}

0 comments on commit ef593fa

Please sign in to comment.