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 cb635b3 commit 0671573
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions src/RobotLoader/RobotLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,39 @@ public function register(bool $prepend = false): self
*/
public function tryLoad(string $type): void
{
$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 0671573

Please sign in to comment.