@@ -28,10 +28,10 @@ class RobotLoader
2828
2929 const RETRY_LIMIT = 3 ;
3030
31- /** @var array comma separated wildcards */
31+ /** @var array */
3232 public $ ignoreDirs = ['.* ' , '*.old ' , '*.bak ' , '*.tmp ' , 'temp ' ];
3333
34- /** @var array comma separated wildcards */
34+ /** @var array */
3535 public $ acceptFiles = ['*.php ' ];
3636
3737 /** @var bool */
@@ -171,6 +171,7 @@ public function getIndexedClasses()
171171 */
172172 public function rebuild ()
173173 {
174+ $ this ->classes = $ this ->missing = [];
174175 $ this ->refresh ();
175176 if ($ this ->tempDirectory ) {
176177 $ this ->saveCache ();
@@ -193,7 +194,8 @@ private function refresh()
193194
194195 $ this ->classes = [];
195196 foreach ($ this ->scanPaths as $ path ) {
196- foreach (is_file ($ path ) ? [new SplFileInfo ($ path )] : $ this ->createFileIterator ($ path ) as $ file ) {
197+ $ iterator = is_file ($ path ) ? [new SplFileInfo ($ path )] : $ this ->createFileIterator ($ path );
198+ foreach ($ iterator as $ file ) {
197199 $ file = $ file ->getPathname ();
198200 if (isset ($ files [$ file ]) && $ files [$ file ]['time ' ] == filemtime ($ file )) {
199201 $ classes = $ files [$ file ]['classes ' ];
@@ -234,7 +236,8 @@ private function createFileIterator($dir)
234236 }
235237 }
236238
237- $ iterator = Nette \Utils \Finder::findFiles (is_array ($ this ->acceptFiles ) ? $ this ->acceptFiles : preg_split ('#[,\s]+# ' , $ this ->acceptFiles ))
239+ $ acceptFiles = is_array ($ this ->acceptFiles ) ? $ this ->acceptFiles : preg_split ('#[,\s]+# ' , $ this ->acceptFiles );
240+ $ iterator = Nette \Utils \Finder::findFiles ($ acceptFiles )
238241 ->filter (function (SplFileInfo $ file ) use (&$ disallow ) {
239242 return !isset ($ disallow [str_replace ('\\' , '/ ' , $ file ->getRealPath ())]);
240243 })
@@ -419,9 +422,7 @@ private function loadCache()
419422
420423 list ($ this ->classes , $ this ->missing ) = @include $ file ; // @ file may not exist
421424 if (!is_array ($ this ->classes )) {
422- $ this ->classes = [];
423- $ this ->refresh ();
424- $ this ->saveCache ();
425+ $ this ->rebuild ();
425426 }
426427
427428 flock ($ handle , LOCK_UN );
0 commit comments