Skip to content

Commit 289fdc2

Browse files
authored
Merge pull request #1 from alies-dev/fix/php-psalm-phpstan-accuracy
fix(php): remove no-op Psalm flags, document PHPStan AgentDetector
2 parents 48990e7 + 5bf47c0 commit 289fdc2

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

php.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
| Pest | `--compact --colors=never` |
99
| ParaTest | `--no-progress --colors=never --display-errors --display-warnings` |
1010
| PHPStan | `--no-progress --no-ansi --error-format=raw` |
11-
| Psalm | `--no-progress --monochrome --show-snippet=false --no-suggestions --output-format=text` |
11+
| Psalm | `--no-progress --no-suggestions --output-format=text` |
1212
| phpcs | `--report=emacs -q --no-colors` |
1313
| phpcbf | `-q --no-colors` |
1414
| PHP-CS-Fixer | `--show-progress=none --no-ansi -n` |
@@ -68,18 +68,20 @@ Other formats: `table` (default, noisy), `json`, `prettyJson`, `checkstyle`, `gi
6868

6969
The `raw` format is the most token-efficient — one line per error. Note: PHPStan prints a `Note: Using configuration file...` line to stderr when auto-discovering a config file.
7070

71+
**PHPStan 2.x agent detection:** PHPStan 2.x includes an `AgentDetector` that checks for env vars like `CLAUDECODE`, `CURSOR_TRACE_ID`, `OPENCODE`, etc. When detected, it prepends a ~600-byte "Instructions for interpreting errors" preamble and appends `[identifier=...]` to each error line in `raw` format. The preamble is emitted on every run regardless of `--error-format`. The identifiers are useful (they name the specific rule), but the preamble adds fixed overhead per invocation.
72+
7173
## Psalm
7274

7375
```bash
74-
vendor/bin/psalm --no-progress --monochrome --show-snippet=false --no-suggestions --output-format=text
76+
vendor/bin/psalm --no-progress --no-suggestions --output-format=text
7577
```
7678

7779
- `--output-format=text` — one error per line: `file:line:col:severity - IssueType: message`
7880
- `--no-progress` — disables progress indicator
79-
- `--monochrome` / `-m` — disables colors
80-
- `--show-snippet=false` — hides code snippets (saves tokens)
8181
- `--no-suggestions` — hides fix suggestions
8282

83+
Note: `--monochrome` and `--show-snippet=false` are sometimes recommended but have no effect with `--output-format=text` — the `text` format never outputs ANSI colors or code snippets (those only appear in the default `console` format).
84+
8385
Other formats: `compact`, `console`, `json`, `json-summary`, `junit`, `by-issue-level`, `count`, `github`, `checkstyle`, `codeclimate`, `emacs`, `phpstorm`, `pylint`, `sarif`, `sonarqube`, `xml`.
8486

8587
[//]: # (> **Psalm 7+:** Use `--output-format=compact` instead of `text` — it becomes a true one-line-per-error format. In Psalm 6 and below, `compact` misleadingly renders box-drawing tables.)
@@ -208,7 +210,7 @@ Copy this into your project's AGENTS.md or CLAUDE.md:
208210
- Tests (with a filter): `vendor/bin/phpunit --no-progress --colors=never --filter=MethodName`
209211
- Tests (Pest): `vendor/bin/pest --compact --colors=never`
210212
- Static analysis (PHPStan): `vendor/bin/phpstan analyse --no-progress --no-ansi --error-format=raw`
211-
- Static analysis (Psalm): `vendor/bin/psalm --no-progress --monochrome --show-snippet=false --no-suggestions --output-format=text`
213+
- Static analysis (Psalm): `vendor/bin/psalm --no-progress --no-suggestions --output-format=text`
212214
- Code style check: `vendor/bin/phpcs --report=emacs -q --no-colors`
213215
- Code style fix (phpcs): `vendor/bin/phpcbf -q --no-colors`
214216
- Code style fix (php-cs-fixer): `vendor/bin/php-cs-fixer fix --show-progress=none --no-ansi -n`

0 commit comments

Comments
 (0)