Skip to content

Commit 40b50bc

Browse files
Testclaude
andcommitted
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>
1 parent 13010ba commit 40b50bc

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

docs/cli/cache-clear.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ GitHooks tries to find the **effective** cache path for each job, in this order
2222

2323
| Tool | Native config source | Default if nothing declared |
2424
|---|---|---|
25-
| **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/` |
2626
| **Psalm** | `cacheDirectory` attribute in `psalm.xml` (resolved relative to the XML) | `.psalm/cache/` |
2727
| **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` |
2929
| **PHPMD** | Job arg `cache-file` | `.phpmd.result.cache` |
3030
| **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` |
3131
| **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
7575

7676
No duplication risk: phpcs **uses** the path you declared, so the runtime cache and the path that `cache:clear` deletes are guaranteed to match.
7777

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+
7884
## PHP-CS-Fixer caveat
7985

8086
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

Comments
 (0)