[Finder] Fixed iterator keys
This commit is contained in:
parent
d16e28acaf
commit
ef593fa8d8
@ -40,6 +40,11 @@ class FilePathsIterator extends \ArrayIterator
|
|||||||
*/
|
*/
|
||||||
private $subPathname;
|
private $subPathname;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var SplFileInfo
|
||||||
|
*/
|
||||||
|
private $current;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $paths List of paths returned by shell command
|
* @param array $paths List of paths returned by shell command
|
||||||
* @param string $baseDir Base dir for relative path building
|
* @param string $baseDir Base dir for relative path building
|
||||||
@ -70,21 +75,27 @@ class FilePathsIterator extends \ArrayIterator
|
|||||||
*/
|
*/
|
||||||
public function current()
|
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()
|
public function next()
|
||||||
{
|
{
|
||||||
parent::next();
|
parent::next();
|
||||||
|
$this->buildProperties();
|
||||||
$this->buildSubPath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rewind()
|
public function rewind()
|
||||||
{
|
{
|
||||||
parent::rewind();
|
parent::rewind();
|
||||||
|
$this->buildProperties();
|
||||||
$this->buildSubPath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,7 +114,7 @@ class FilePathsIterator extends \ArrayIterator
|
|||||||
return $this->subPathname;
|
return $this->subPathname;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildSubPath()
|
private function buildProperties()
|
||||||
{
|
{
|
||||||
$absolutePath = parent::current();
|
$absolutePath = parent::current();
|
||||||
|
|
||||||
@ -114,5 +125,7 @@ class FilePathsIterator extends \ArrayIterator
|
|||||||
} else {
|
} else {
|
||||||
$this->subPath = $this->subPathname = '';
|
$this->subPath = $this->subPathname = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->current = new SplFileInfo(parent::current(), $this->subPath, $this->subPathname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user