@@ -97,7 +97,7 @@ public function __wakeup(): void
97
97
98
98
public function getIterator (): \Traversable
99
99
{
100
- if (! file_exists ( $ this -> prefix ) || ( !$ this ->recursive && '' === $ this ->pattern )) {
100
+ if (( !$ this ->recursive && '' === $ this ->pattern ) || ! file_exists ( $ this -> prefix )) {
101
101
return ;
102
102
}
103
103
@@ -148,7 +148,7 @@ public function getIterator(): \Traversable
148
148
} while ($ prefix !== $ dirPath && $ dirPath !== $ normalizedPath = \dirname ($ dirPath ));
149
149
}
150
150
151
- if (is_file ( $ path ) && ( null === $ regex || preg_match ($ regex , substr (str_replace ('\\' , '/ ' , $ path ), $ prefixLen )))) {
151
+ if (( null === $ regex || preg_match ($ regex , substr (str_replace ('\\' , '/ ' , $ path ), $ prefixLen ))) && is_file ( $ path )) {
152
152
yield $ path => new \SplFileInfo ($ path );
153
153
}
154
154
if (!is_dir ($ path )) {
@@ -165,7 +165,7 @@ public function getIterator(): \Traversable
165
165
new \RecursiveCallbackFilterIterator (
166
166
new \RecursiveDirectoryIterator ($ path , \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS ),
167
167
fn (\SplFileInfo $ file , $ path ) => !isset ($ this ->excludedPrefixes [$ path = str_replace ('\\' , '/ ' , $ path )])
168
- && (null === $ regex || $ file -> isDir () || preg_match ($ regex , substr ($ path , $ prefixLen )))
168
+ && (null === $ regex || preg_match ($ regex , substr ($ path , $ prefixLen )) || $ file -> isDir ( ))
169
169
&& '. ' !== $ file ->getBasename ()[0 ]
170
170
),
171
171
\RecursiveIteratorIterator::LEAVES_ONLY
0 commit comments