File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,9 @@ class RobotLoader
66
66
/** @var string|null */
67
67
private $ tempDirectory ;
68
68
69
+ /** @var bool */
70
+ private $ needSave = false ;
71
+
69
72
70
73
public function __construct ()
71
74
{
@@ -75,6 +78,14 @@ public function __construct()
75
78
}
76
79
77
80
81
+ public function __destruct ()
82
+ {
83
+ if ($ this ->needSave ) {
84
+ $ this ->saveCache ();
85
+ }
86
+ }
87
+
88
+
78
89
/**
79
90
* Register autoloader.
80
91
*/
@@ -100,31 +111,25 @@ public function tryLoad(string $type): void
100
111
[$ file , $ mtime ] = $ this ->classes [$ type ] ?? null ;
101
112
102
113
if ($ this ->autoRebuild ) {
103
- $ save = false ;
104
-
105
114
if (!$ this ->refreshed ) {
106
115
if (!$ file || !is_file ($ file )) {
107
116
$ this ->refreshClasses ();
108
117
[$ file ] = $ this ->classes [$ type ] ?? null ;
109
- $ save = true ;
118
+ $ this -> needSave = true ;
110
119
111
120
} elseif (filemtime ($ file ) !== $ mtime ) {
112
121
$ this ->updateFile ($ file );
113
122
[$ file ] = $ this ->classes [$ type ] ?? null ;
114
- $ save = true ;
123
+ $ this -> needSave = true ;
115
124
}
116
125
}
117
126
118
127
if (!$ file || !is_file ($ file )) {
119
128
$ this ->missingClasses [$ type ] = ++$ missing ;
120
- $ save = $ save || $ file || ($ missing <= self ::RETRY_LIMIT );
129
+ $ this -> needSave = $ this -> needSave || $ file || ($ missing <= self ::RETRY_LIMIT );
121
130
unset($ this ->classes [$ type ]);
122
131
$ file = null ;
123
132
}
124
-
125
- if ($ save ) {
126
- $ this ->saveCache ();
127
- }
128
133
}
129
134
130
135
if ($ file ) {
You can’t perform that action at this time.
0 commit comments