@@ -88,28 +88,40 @@ public function register(bool $prepend = false): self
88
88
public function tryLoad (string $ type ): void
89
89
{
90
90
$ this ->loadCache ();
91
+
92
+ $ missing = $ this ->missing [$ type ] ?? null ;
93
+ if ($ missing >= self ::RETRY_LIMIT ) {
94
+ return ;
95
+ }
96
+
91
97
$ info = $ this ->classes [$ type ] ?? null ;
92
98
93
99
if ($ this ->autoRebuild ) {
94
- if (! $ info || ! is_file ( $ info [ ' file ' ])) {
95
- $ missing = & $ this -> missing [ $ type ];
96
- $ missing ++;
97
- if (!$ this -> refreshed && $ missing <= self :: RETRY_LIMIT ) {
100
+ $ save = false ;
101
+
102
+ if (! $ this -> refreshed ) {
103
+ if (!$ info || ! is_file ( $ info [ ' file ' ]) ) {
98
104
$ this ->refreshClasses ();
99
- $ this ->saveCache ();
100
- } elseif ($ info ) {
101
- unset($ this ->classes [$ type ]);
102
- $ this ->saveCache ();
103
- }
105
+ $ info = $ this ->classes [$ type ] ?? null ;
106
+ $ save = true ;
104
107
105
- } elseif (! $ this -> refreshed && filemtime ($ info ['file ' ]) !== $ info ['time ' ]) {
106
- $ this ->updateFile ($ info ['file ' ]);
107
- if ( empty ( $ this ->classes [$ type ])) {
108
- $ this -> missing [ $ type ] = 0 ;
108
+ } elseif (filemtime ($ info ['file ' ]) !== $ info ['time ' ]) {
109
+ $ this ->updateFile ($ info ['file ' ]);
110
+ $ info = $ this ->classes [$ type ] ?? null ;
111
+ $ save = true ;
109
112
}
113
+ }
114
+
115
+ if (!$ info || !is_file ($ info ['file ' ])) {
116
+ $ this ->missing [$ type ] = ++$ missing ;
117
+ $ save = $ save || $ info || ($ missing <= self ::RETRY_LIMIT );
118
+ unset($ this ->classes [$ type ]);
119
+ $ info = null ;
120
+ }
121
+
122
+ if ($ save ) {
110
123
$ this ->saveCache ();
111
124
}
112
- $ info = $ this ->classes [$ type ] ?? null ;
113
125
}
114
126
115
127
if ($ info ) {
0 commit comments