From 2301a42476227d09986f286cc0c64e081a7667e7 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Wed, 19 Feb 2020 10:37:08 +0100 Subject: [PATCH] :bug: Fix iterator for file list --- TwigCS/src/Config/Config.php | 20 +++++++++++--------- TwigCS/src/Config/TwigFileFilter.php | 8 -------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/TwigCS/src/Config/Config.php b/TwigCS/src/Config/Config.php index d00461d..06ef16e 100644 --- a/TwigCS/src/Config/Config.php +++ b/TwigCS/src/Config/Config.php @@ -36,16 +36,18 @@ public function findFiles(): array if (is_dir($path)) { $flags = \RecursiveDirectoryIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS; $directoryIterator = new \RecursiveDirectoryIterator($path, $flags); - } else { - $directoryIterator = new \RecursiveArrayIterator([new \SplFileInfo($path)]); - } - - $filter = new TwigFileFilter($directoryIterator); - $iterator = new \RecursiveIteratorIterator($filter); - - /** @var \SplFileInfo $file */ - foreach ($iterator as $file) { + $filter = new TwigFileFilter($directoryIterator); + $iterator = new \RecursiveIteratorIterator($filter); + + /** @var \SplFileInfo $file */ + foreach ($iterator as $k => $file) { + $files[] = $file->getRealPath(); + } + } elseif (is_file($path)) { + $file = new \SplFileInfo($path); $files[] = $file->getRealPath(); + } else { + throw new Exception(sprintf('Unknown path: "%s"', $path)); } } diff --git a/TwigCS/src/Config/TwigFileFilter.php b/TwigCS/src/Config/TwigFileFilter.php index 2bcb125..2ebb586 100644 --- a/TwigCS/src/Config/TwigFileFilter.php +++ b/TwigCS/src/Config/TwigFileFilter.php @@ -7,14 +7,6 @@ */ class TwigFileFilter extends \RecursiveFilterIterator { - /** - * @param \RecursiveIterator $iterator - */ - public function __construct(\RecursiveIterator $iterator) - { - parent::__construct($iterator); - } - /** * @return bool */