Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 1, 2019
1 parent fd51dae commit a4a0431
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/RobotLoader/RobotLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class RobotLoader

const RETRY_LIMIT = 3;

/** @var array comma separated wildcards */
/** @var array */
public $ignoreDirs = ['.*', '*.old', '*.bak', '*.tmp', 'temp'];

/** @var array comma separated wildcards */
/** @var array */
public $acceptFiles = ['*.php'];

/** @var bool */
Expand Down Expand Up @@ -171,6 +171,7 @@ public function getIndexedClasses()
*/
public function rebuild()
{
$this->classes = $this->missing = [];
$this->refresh();
if ($this->tempDirectory) {
$this->saveCache();
Expand All @@ -193,7 +194,8 @@ private function refresh()

$this->classes = [];
foreach ($this->scanPaths as $path) {
foreach (is_file($path) ? [new SplFileInfo($path)] : $this->createFileIterator($path) as $file) {
$iterator = is_file($path) ? [new SplFileInfo($path)] : $this->createFileIterator($path);
foreach ($iterator as $file) {
$file = $file->getPathname();
if (isset($files[$file]) && $files[$file]['time'] == filemtime($file)) {
$classes = $files[$file]['classes'];
Expand Down Expand Up @@ -234,7 +236,8 @@ private function createFileIterator($dir)
}
}

$iterator = Nette\Utils\Finder::findFiles(is_array($this->acceptFiles) ? $this->acceptFiles : preg_split('#[,\s]+#', $this->acceptFiles))
$acceptFiles = is_array($this->acceptFiles) ? $this->acceptFiles : preg_split('#[,\s]+#', $this->acceptFiles);
$iterator = Nette\Utils\Finder::findFiles($acceptFiles)
->filter(function (SplFileInfo $file) use (&$disallow) {
return !isset($disallow[str_replace('\\', '/', $file->getRealPath())]);
})
Expand Down Expand Up @@ -419,9 +422,7 @@ private function loadCache()

list($this->classes, $this->missing) = @include $file; // @ file may not exist
if (!is_array($this->classes)) {
$this->classes = [];
$this->refresh();
$this->saveCache();
$this->rebuild();
}

flock($handle, LOCK_UN);
Expand Down

0 comments on commit a4a0431

Please sign in to comment.