From 905e9113c4dd372bfa70b7bb64d0c97d58a9f174 Mon Sep 17 00:00:00 2001 From: norb Date: Tue, 11 Feb 2025 08:14:07 +0100 Subject: [PATCH 1/2] fix: files should always be ignored as they cannot be Instances --- src/InstanceIterator.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/InstanceIterator.php b/src/InstanceIterator.php index 1c028cc..916b730 100644 --- a/src/InstanceIterator.php +++ b/src/InstanceIterator.php @@ -28,9 +28,15 @@ class InstanceIterator extends \FilesystemIterator public function current() { + // skip files + while (! parent::current()->isDir()) { + parent::next(); + } + if (!isset($this->instance)) { $this->instance = new Instance(parent::current()); } + // var_dump($this); return $this->instance; } @@ -40,4 +46,4 @@ class InstanceIterator extends \FilesystemIterator $this->instance = null; parent::next(); } -} \ No newline at end of file +} From 68ce3782e1ae68b8593fe020743da7303a53e299 Mon Sep 17 00:00:00 2001 From: norb Date: Tue, 11 Feb 2025 08:19:54 +0100 Subject: [PATCH 2/2] test WIP: not a unit test yet but heading there --- tests/InstanceIteratorTest.php | 5 +++-- tests/instances/a/.rev | 0 tests/instances/b/.rev | 0 tests/instances/c/.rev | 0 tests/instances/d/.rev | 0 tests/instances/e/.rev | 0 tests/instances/f/.rev | 0 tests/instances/file | 0 8 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 tests/instances/a/.rev create mode 100644 tests/instances/b/.rev create mode 100644 tests/instances/c/.rev create mode 100644 tests/instances/d/.rev create mode 100644 tests/instances/e/.rev create mode 100644 tests/instances/f/.rev create mode 100644 tests/instances/file diff --git a/tests/InstanceIteratorTest.php b/tests/InstanceIteratorTest.php index f3365d7..7820674 100644 --- a/tests/InstanceIteratorTest.php +++ b/tests/InstanceIteratorTest.php @@ -1,8 +1,9 @@