Skip to content

Commit

Permalink
fixed buggy behavior after 788ab3e
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 6, 2021
1 parent 0103ba3 commit 9ad3afd
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions src/RobotLoader/RobotLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,40 @@ public function register(bool $prepend = false): self
public function tryLoad(string $type): void
{
$this->loadCache();

$missing = $this->missing[$type] ?? null;
if ($missing >= self::RETRY_LIMIT) {
return;
}

$info = $this->classes[$type] ?? null;

if ($this->autoRebuild) {
if (!$info || !is_file($info['file'])) {
$missing = &$this->missing[$type];
$missing++;
if (!$this->refreshed && $missing <= self::RETRY_LIMIT) {
$save = false;

if (!$this->refreshed) {
if (!$info || !is_file($info['file'])) {
$this->refreshClasses();
$this->saveCache();
} elseif ($info) {
unset($this->classes[$type]);
$this->saveCache();
}
$info = $this->classes[$type] ?? null;
$save = true;

} elseif (!$this->refreshed && filemtime($info['file']) !== $info['time']) {
$this->updateFile($info['file']);
if (empty($this->classes[$type])) {
$this->missing[$type] = 0;
} elseif (filemtime($info['file']) !== $info['time']) {
$this->updateFile($info['file']);
$info = $this->classes[$type] ?? null;
$save = true;
}
}

if (!$info || !is_file($info['file'])) {
$this->missing[$type] = ++$missing;
$save = $save || $info || ($missing <= self::RETRY_LIMIT);
unset($this->classes[$type]);
$info = null;
}

if ($save) {
$this->saveCache();
}
$info = $this->classes[$type] ?? null;
}

if ($info) {
Expand Down

0 comments on commit 9ad3afd

Please sign in to comment.