File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ CHANGELOG
5
5
-----
6
6
7
7
* deprecated ` Symfony\Component\Finder\Iterator\FilterIterator `
8
+ * added Finder::hasResults() method to check if any results were found
8
9
9
10
3.3.0
10
11
-----
Original file line number Diff line number Diff line change @@ -613,6 +613,20 @@ public function append($iterator)
613
613
return $ this ;
614
614
}
615
615
616
+ /**
617
+ * Check if the any results were found.
618
+ *
619
+ * @return bool
620
+ */
621
+ public function hasResults ()
622
+ {
623
+ foreach ($ this ->getIterator () as $ _ ) {
624
+ return true ;
625
+ }
626
+
627
+ return false ;
628
+ }
629
+
616
630
/**
617
631
* Counts all the results collected by the iterators.
618
632
*
Original file line number Diff line number Diff line change @@ -424,6 +424,20 @@ public function testCountWithoutIn()
424
424
count ($ finder );
425
425
}
426
426
427
+ public function testHasResults ()
428
+ {
429
+ $ finder = $ this ->buildFinder ();
430
+ $ finder ->in (__DIR__ );
431
+ $ this ->assertTrue ($ finder ->hasResults ());
432
+ }
433
+
434
+ public function testNoResults ()
435
+ {
436
+ $ finder = $ this ->buildFinder ();
437
+ $ finder ->in (__DIR__ )->name ('DoesNotExist ' );
438
+ $ this ->assertFalse ($ finder ->hasResults ());
439
+ }
440
+
427
441
/**
428
442
* @dataProvider getContainsTestData
429
443
*/
You can’t perform that action at this time.
0 commit comments