Skip to content

Commit

Permalink
Merge pull request #54 from funivan/fix-cache
Browse files Browse the repository at this point in the history
Store file information in the cache with correct
  • Loading branch information
overtrue authored Dec 6, 2018
2 parents 60b3dfa + ced6710 commit 4a18243
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Linter.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,17 @@ public function lint($files = [], $cache = true)
for ($i = count($running); !empty($files) && $i < $this->processLimit; ++$i) {
$file = array_shift($files);
$filename = $file->getRealPath();
$key = $file->getRelativePathname();
if (!isset($this->cache[$key]) || $this->cache[$key] !== md5_file($filename)) {
$relativePathname = $file->getRelativePathname();
if (!isset($this->cache[$relativePathname]) || $this->cache[$relativePathname] !== md5_file($filename)) {
$lint = new Lint(escapeshellcmd($phpbin).' -d error_reporting=E_ALL -d display_errors=On -l '.escapeshellarg($filename));
$running[$filename] = [
'process' => $lint,
'file' => $file,
'relativePath' => $relativePathname,
];
$lint->start();
} else {
$newCache[$key] = $this->cache[$key];
$newCache[$relativePathname] = $this->cache[$relativePathname];
}
}

Expand All @@ -121,7 +122,7 @@ public function lint($files = [], $cache = true)
$processCallback('error', $item['file']);
$errors[$filename] = array_merge(['file' => $filename], $lint->getSyntaxError());
} else {
$newCache[$filename] = md5_file($filename);
$newCache[$item['relativePath']] = md5_file($filename);
$processCallback('ok', $item['file']);
}
}
Expand Down

0 comments on commit 4a18243

Please sign in to comment.