@@ -88,28 +88,40 @@ public function register(bool $prepend = false): self
8888 public function tryLoad (string $ type ): void
8989 {
9090 $ this ->loadCache ();
91+
92+ $ missing = $ this ->missing [$ type ] ?? null ;
93+ if ($ missing >= self ::RETRY_LIMIT ) {
94+ return ;
95+ }
96+
9197 $ info = $ this ->classes [$ type ] ?? null ;
9298
9399 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 ' ]) ) {
98104 $ 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 ;
104107
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 ;
109112 }
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 ) {
110123 $ this ->saveCache ();
111124 }
112- $ info = $ this ->classes [$ type ] ?? null ;
113125 }
114126
115127 if ($ info ) {
0 commit comments