File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,8 @@ class FileTypeMapper
63
63
/** @var NameScope[][] */
64
64
private array $ memoryCache = [];
65
65
66
+ private int $ memoryCacheCount = 0 ;
67
+
66
68
/** @var (false|callable(): NameScope|NameScope)[][] */
67
69
private array $ inProcess = [];
68
70
@@ -211,7 +213,18 @@ private function getNameScopeMap(string $fileName): array
211
213
$ this ->cache ->save ($ cacheKey , $ variableCacheKey , $ map );
212
214
}
213
215
216
+ if ($ this ->memoryCacheCount >= 512 ) {
217
+ $ this ->memoryCache = array_slice (
218
+ $ this ->memoryCache ,
219
+ 1 ,
220
+ null ,
221
+ true ,
222
+ );
223
+ $ this ->memoryCacheCount --;
224
+ }
225
+
214
226
$ this ->memoryCache [$ fileName ] = $ map ;
227
+ $ this ->memoryCacheCount ++;
215
228
}
216
229
217
230
return $ this ->memoryCache [$ fileName ];
You can’t perform that action at this time.
0 commit comments