PHPStan caches the result of the analysis so the subsequent runs are much faster. You should always analyse the whole project - the list of paths passed to the
analyse command should be the same to take advantage of the result cache. If the list of paths differs from run to run, the cache is rebuilt from the ground up each time.
You might notice the result cache isn’t sometimes saved and PHPStan runs full analysis even if nothing changed since the last run. If the analysis result contains some serious errors like parse errors, result cache cannot be used for the next run because the files dependency tree might be incomplete.
The result cache is saved at
%tmpDir%/result-cache.php. Learn more about
tmpDir configuration »
Result cache contents #
- The last time a full analysis of the project was performed. The full analysis is performed at least every 7 days.
- Analysis variables used to invalidate a stale cache. If any of these values change, full analysis is performed again.
- Errors in the last run
- Dependency tree of project files. If file
A.phpwas modified since the last run,
A.phpand all the files calling or otherwise referencing all the symbols in
A.phpare analysed again.
Clearing the result cache #
To clear the current state of the result cache, for example if you’re developing custom extensions and the result cache is getting stale too often, you can run the
clear-result-cache command. Learn more »
Result cache also gets disabled when running with