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
docs(cache:clear): document PHPUnit precedence and PHPStan tmpDir scope
The 3.3.1 cache:clear fix changed two pieces of behaviour that the user
needs to know about, but the doc page covered them only implicitly:
- PHPUnit `cacheDirectory` (PHPUnit 10+) now takes precedence over
`cacheResultFile` when both are declared, matching PHPUnit's own
resolution order. The previous wording listed both attributes with
`/` ambiguous about which one wins. Surface the precedence in the
resolution table and add a dedicated section paralleling the existing
"PHPCS with chained rulesets" / "PHP-CS-Fixer caveat" entries so
users searching for "PHPUnit 10 cache" land on the right paragraph.
- PHPStan `tmpDir:` is read only under the top-level `parameters:`
block; declarations under `services:` (e.g. a service constructor
argument named `tmpDir`) are intentionally ignored. Add this scope
constraint to the resolution table along with the cycle-safe note.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|**PHPStan**|`tmpDir:` in the `.neon` (follows `includes:` recursively, expands `%currentWorkingDirectory%` and `%rootDir%`) |`{sys_get_temp_dir}/phpstan/`|
25
+
|**PHPStan**|`tmpDir:`under the top-level `parameters:` block in the `.neon` (follows `includes:` recursively and cycle-safe; expands `%currentWorkingDirectory%` and `%rootDir%`; `tmpDir:` declared inside `services:` is intentionally ignored) |`{sys_get_temp_dir}/phpstan/`|
26
26
|**Psalm**|`cacheDirectory` attribute in `psalm.xml` (resolved relative to the XML) |`.psalm/cache/`|
27
27
|**PHPCS**| Job arg `cache` → `<arg name="cache" value="..."/>` in the ruleset XML |`.phpcs.cache`|
28
-
|**PHPUnit**|`cacheResultFile` / `cacheDirectory` attribute in `phpunit.xml` (or `phpunit.xml.dist`, resolved relative to the XML) |`.phpunit.result.cache`|
28
+
|**PHPUnit**|`cacheDirectory` attribute in `phpunit.xml` (PHPUnit 10+, takes precedence) → `cacheResultFile` (legacy fallback). Both resolved relative to `phpunit.xml` (or `phpunit.xml.dist`) |`.phpunit.result.cache`|
|**Rector**| Best-effort regex over `cacheDirectory(...)` in `rector.php` (recognises literals, `__DIR__ . '/literal'`, `sys_get_temp_dir() . '/literal'`) |`{sys_get_temp_dir}/rector_cached_files`|
31
31
|**PHP-CS-Fixer**| Job arg `cache-file` (passed as `--cache-file` to the tool, which respects it over the config) → best-effort regex over `setCacheFile(...)` in `.php-cs-fixer.php`|`.php-cs-fixer.cache`|
@@ -75,6 +75,12 @@ The fix is the same single-source-of-truth pattern as PHP-CS-Fixer: declare `cac
75
75
76
76
No duplication risk: phpcs **uses** the path you declared, so the runtime cache and the path that `cache:clear` deletes are guaranteed to match.
77
77
78
+
## PHPUnit `cacheDirectory` vs `cacheResultFile`
79
+
80
+
PHPUnit 10 introduced `cacheDirectory` and deprecated the legacy `cacheResultFile`. Projects in transition often keep both attributes in `phpunit.xml` for backward compatibility. PHPUnit itself prefers `cacheDirectory` when both are declared; `cache:clear` now matches that precedence — `cacheDirectory` is read first, `cacheResultFile` only as fallback.
81
+
82
+
If your `phpunit.xml` declares only one of the two attributes, the resolution is unambiguous and works as before.
83
+
78
84
## PHP-CS-Fixer caveat
79
85
80
86
If `.php-cs-fixer.php` sets `setCacheFile()` with a dynamic expression, the same warning is emitted. **Do not** add a meta-arg here — instead use `cache-file` on the job:
0 commit comments