Repository navigation
Save the result cache when a file has a parse error - #6694
Conversation
c685bef to
2bb1624
Compare
2bb1624 to
b4754b6
Compare
|
please test how this affects numbers reported for symfony with https://github.com/TomasVotruba/need-for-speed |
|
I ran it with the Symfony setup of need-for-speed: their
This PR alone does not change the Symfony number. The parse error in The last row adds the change for inheritance cycles: ondrejmirtes/BetterReflection#47, and the phpstan-src part that I have ready locally until a release of it. With both, the result cache is saved, and the hot run re-analyses only One note on their numbers: |
A file with a parse error is left out of the result cache and analysed again on every run, so the rest of the result cache is saved. Other exceptions, including reflection errors, still stop the save. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
b4754b6 to
206410f
Compare
|
Thank you! |
A parse error in one analysed file stopped PHPStan from saving the result cache. So every run analysed the whole project again.
Now the result cache is saved without the results of a file with a parse error. Its recorded hash gets a
reanalyse:prefix, so PHPStan analyses it again on every run. When the file is fixed and now declares a symbol, the usual rule applies: the files with errors are analysed again.Any other exception still stops the save, including reflection errors. A rule that throws already stopped the save before this check, in a worker and in-process, because the dependencies are then missing. A parse error that is reported in a file that is not analysed also still stops the save.
Unchanged: while a parse error exists,
AnalyseCommandstill shows only the parse errors and hides the others.This does not make the result cache work on symfony/symfony on its own. Its tests in
srcalso containclass NotLoadableClass extends NotLoadableClass, which gives a reflection error inNotLoadableClass.phpandReflectionCasterTest.php. Those two files still stop the save.Verification:
result-cache-parse-error:reanalyse:prefix is left out,result-cache-internal-error: a rule that throws. The result cache is not saved. This passes on the base too, and guards the behaviour.2bb7fc81a(12,098 files), level 8, from source without turbo, with the two reflection-error files excluded:Config/Tests/Fixtures/ParseError.php, and this PR writes it.ParseError.phpon a saved cache. The next run analysed 6,602 files, and its output matched a cold run on all 70,346 lines outsideForm/Form.phpandForm/FormErrorIterator.php. Those two files give different errors between two cold runs too.make testspasses (22,503 tests, 74 skipped).make phpstanreports no errors, and phpcs passes onResultCacheManager.php.🤖 Generated with Claude Code