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