Skip to content

Commit

Permalink
Refs #531 - add iterator support to DirSet/FileSet
Browse files Browse the repository at this point in the history
  • Loading branch information
mrook committed Jan 16, 2017
1 parent 06580be commit a646caa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 3 additions & 1 deletion classes/phing/types/AbstractFileSet.php
Expand Up @@ -69,7 +69,7 @@
* @see ProjectComponent
* @package phing.types
*/
class AbstractFileSet extends DataType implements SelectorContainer
abstract class AbstractFileSet extends DataType implements SelectorContainer, IteratorAggregate
{

// These vars are public for cloning purposes
Expand Down Expand Up @@ -749,4 +749,6 @@ public function createDifferent()

return $o;
}

abstract public function getIterator();
}
9 changes: 8 additions & 1 deletion classes/phing/types/DirSet.php
Expand Up @@ -28,7 +28,7 @@
*
* @package phing.types
*/
class DirSet extends AbstractFileSet
class DirSet extends AbstractFileSet implements IteratorAggregate
{

/**
Expand All @@ -52,4 +52,11 @@ public function __clone()
}
}

/**
* @return array
*/
public function getIterator()
{
return $this->getDirectoryScanner($this->getProject())->getIncludedDirectories();
}
}
11 changes: 10 additions & 1 deletion classes/phing/types/FileSet.php
Expand Up @@ -34,7 +34,7 @@
* @author Stefan Bodewig <stefan.bodewig@epost.de> (Ant)
* @author Magesh Umasankar (Ant)
*/
class FileSet extends AbstractFileSet
class FileSet extends AbstractFileSet implements IteratorAggregate
{
/**
* Return a FileSet that has the same basedir and same patternsets as this one.
Expand All @@ -47,4 +47,13 @@ public function __clone()
return new FileSet($this);
}
}

/**
* @return array
*/
public function getIterator()
{
$ds = $this->getDirectoryScanner($this->getProject());
return $ds->getIncludedFiles() + $ds->getIncludedDirectories();
}
}

0 comments on commit a646caa

Please sign in to comment.