You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ac8e035
Browse filesBrowse the repository at this point in the historyBrowse files
Reproduce the result cache keeping an error from a rule built on collected data
Rules that read collected data run in AnalyserResultFinalizer, and the result
cache is written before that, so their errors are never in the cached error
map. That map is what restore() sweeps when a new file appears - the recovery
for an error that could record no dependency, because the symbol it is about
did not exist yet. A file whose only error comes from collected data is never
in that sweep, so it keeps the error after the symbol arrives, while a run
from a cleared cache reports nothing.
src/Caller.php calls an unqualified function that falls back to a pure global
one, so its only error comes from a CollectedDataNode rule. src/PlainCaller.php
has an ordinary error and is there to prove the sweep ran at all. Creating
src/nsfns.php defines both missing symbols at once: the ordinary error goes
away, the collector-backed one does not.
The test fails: the cached run reports one error and exits 1, a run with a
cleared cache reports none.
Copy file name to clipboardExpand all lines: .github/workflows/e2e-tests.yml
+15Lines changed: 15 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -901,6 +901,21 @@ jobs:
901
901
echo "$OUTPUT"
902
902
../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT"
903
903
../bashunit -a contains 'UsesCopied.php:16:Method ResultCacheE2EPathRepository\UsesCopied::doUsesCopied() should return int but returns string.' "$OUTPUT"
904
+
- script: |
905
+
cd e2e/result-cache-collector-sweep
906
+
# Two errors: one from an ordinary rule, one from a rule built on collected data.
907
+
OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw")
908
+
echo "$OUTPUT"
909
+
../bashunit -a contains 'PlainCaller.php:8:Method ResultCacheE2ECollectorSweep\PlainCaller::doPlainCaller() has invalid return type ResultCacheE2ECollectorSweep\Missing.' "$OUTPUT"
910
+
../bashunit -a contains 'Caller.php:7:Call to function resultCacheE2ECollectorHelper() on a separate line has no effect.' "$OUTPUT"
911
+
# One new file defines both missing symbols. The files with errors are re-analysed - but
912
+
# the errors of the collector-backed rule are produced after the cache is written, so the
913
+
# file holding one is not in the cached error map and never gets swept.
914
+
cp appears/nsfns.php src/nsfns.php
915
+
OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv --error-format raw")
916
+
echo "$OUTPUT"
917
+
../bashunit -a not_contains 'has invalid return type' "$OUTPUT"
918
+
../bashunit -a not_contains 'on a separate line has no effect' "$OUTPUT"
0 commit comments