Skip to content

Commit

Permalink
added refresh()
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 1, 2019
1 parent a4a0431 commit 591a651
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/RobotLoader/RobotLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function tryLoad($type)
$missing = &$this->missing[$type];
$missing++;
if (!$this->refreshed && $missing <= self::RETRY_LIMIT) {
$this->refresh();
$this->refreshClasses();
$this->saveCache();
} elseif ($info) {
unset($this->classes[$type]);
Expand Down Expand Up @@ -172,20 +172,34 @@ public function getIndexedClasses()
public function rebuild()
{
$this->classes = $this->missing = [];
$this->refresh();
$this->refreshClasses();
if ($this->tempDirectory) {
$this->saveCache();
}
}


/**
* Refreshes class list.
* Refreshes class list cache.
* @return void
*/
private function refresh()
public function refresh()
{
$this->refreshed = true; // prevents calling refresh() or updateFile() in tryLoad()
$this->loadCache();
if (!$this->refreshed) {
$this->refreshClasses();
$this->saveCache();
}
}


/**
* Refreshes $classes.
* @return void
*/
private function refreshClasses()
{
$this->refreshed = true; // prevents calling refreshClasses() or updateFile() in tryLoad()
$files = [];
foreach ($this->classes as $class => $info) {
$files[$info['file']]['time'] = $info['time'];
Expand Down

0 comments on commit 591a651

Please sign in to comment.