1- <?php
1+ <?php declare (strict_types= 1 );
22/**
3- * Created by PhpStorm.
4- * User: Inhere
5- * Date: 2018/1/20 0020
6- * Time: 21:57
3+ * This file is part of toolkit/fsutil.
4+ *
5+ * @author https://github.com/inhere
6+ * @link https://github.com/toolkit/fsutil
7+ * @license MIT
78 */
89
910namespace Toolkit \FsUtil ;
5758final class FileFinder implements IteratorAggregate, Countable
5859{
5960 public const ONLY_FILE = 1 ;
61+
6062 public const ONLY_DIR = 2 ;
63+
6164 public const IGNORE_VCS_FILES = 1 ;
65+
6266 public const IGNORE_DOT_FILES = 2 ;
6367
6468 /** @var array */
@@ -470,12 +474,15 @@ private function findInDirectory(string $dir): Iterator
470474 $ flags |= RecursiveDirectoryIterator::FOLLOW_SYMLINKS ;
471475 }
472476
473- $ iterator = new class ($ dir , $ flags ) extends RecursiveDirectoryIterator
474- {
477+ $ iterator = new class ($ dir , $ flags ) extends RecursiveDirectoryIterator {
475478 private $ rootPath ;
479+
476480 private $ subPath ;
481+
477482 private $ rewindable ;
483+
478484 private $ directorySeparator = '/ ' ;
485+
479486 private $ ignoreUnreadableDirs ;
480487
481488 public function __construct (string $ path , int $ flags , bool $ ignoreUnreadableDirs = false )
@@ -565,9 +572,9 @@ public function isRewindable()
565572
566573 // exclude directories
567574 if ($ this ->excludes ) {
568- $ iterator = new class ($ iterator , $ this ->excludes ) extends FilterIterator implements RecursiveIterator
569- {
575+ $ iterator = new class ($ iterator , $ this ->excludes ) extends FilterIterator implements RecursiveIterator {
570576 private $ excludes ;
577+
571578 private $ iterator ;
572579
573580 public function __construct (RecursiveIterator $ iterator , array $ excludes )
@@ -605,8 +612,7 @@ public function getChildren()
605612
606613 // mode: find files or dirs
607614 if ($ this ->mode ) {
608- $ iterator = new class ($ iterator , $ this ->mode ) extends FilterIterator
609- {
615+ $ iterator = new class ($ iterator , $ this ->mode ) extends FilterIterator {
610616 private $ mode ;
611617
612618 public function __construct (Iterator $ iterator , int $ mode )
@@ -632,9 +638,9 @@ public function accept(): bool
632638 }
633639
634640 if ($ this ->names || $ this ->notNames ) {
635- $ iterator = new class ($ iterator , $ this ->names , $ this ->notNames ) extends FilterIterator
636- {
641+ $ iterator = new class ($ iterator , $ this ->names , $ this ->notNames ) extends FilterIterator {
637642 private $ names ;
643+
638644 private $ notNames ;
639645
640646 public function __construct (Iterator $ iterator , array $ names , array $ notNames )
@@ -670,8 +676,7 @@ public function accept(): bool
670676 }
671677
672678 if ($ this ->filters ) {
673- $ iterator = new class ($ iterator , $ this ->filters ) extends FilterIterator
674- {
679+ $ iterator = new class ($ iterator , $ this ->filters ) extends FilterIterator {
675680 private $ filters ;
676681
677682 public function __construct (Iterator $ iterator , array $ filters )
@@ -695,9 +700,9 @@ public function accept(): bool
695700 }
696701
697702 if ($ this ->paths || $ this ->notPaths ) {
698- $ iterator = new class ($ iterator , $ this ->paths , $ this ->notPaths ) extends FilterIterator
699- {
703+ $ iterator = new class ($ iterator , $ this ->paths , $ this ->notPaths ) extends FilterIterator {
700704 private $ paths ;
705+
701706 private $ notPaths ;
702707
703708 public function __construct (Iterator $ iterator , array $ paths , array $ notPaths )
0 commit comments