---
title: "PHPStan PHP static analysis"
description: "Runs PHPStan 2 over PHP files at level 5 (settings[\"code.phpstan\"].level: 0-10 or \"max\"). The project's phpstan.neon(.dist) is ignored because it can declare bootstrapFiles, includes and extensions that execute PHP; PHPStan instead gets a generated config listing the files, and runs from an empty temp directory so it never requires the project's Composer autoloader (vendor/autoload.php), which it otherwise loads from the working directory. Analysis is then purely static: no target code runs. An installed vendor/ directory is only scanned statically for symbols; without one, unknown classes and functions are reported with low confidence. Files that do not parse are reported and the rest re-analysed."
url: https://openaudit.se/auditors/code.phpstan/
---

# PHPStan PHP static analysis

`code.phpstan`

Runs PHPStan 2 over PHP files at level 5 (settings["code.phpstan"].level: 0-10 or "max"). The project's phpstan.neon(.dist) is ignored because it can declare bootstrapFiles, includes and extensions that execute PHP; PHPStan instead gets a generated config listing the files, and runs from an empty temp directory so it never requires the project's Composer autoloader (vendor/autoload.php), which it otherwise loads from the working directory. Analysis is then purely static: no target code runs. An installed vendor/ directory is only scanned statically for symbols; without one, unknown classes and functions are reported with low confidence. Files that do not parse are reported and the rest re-analysed.

- **Engine:** Wrapped scanner
- **Wraps:** `phpstan`
- **Targets:** Codebase
- **Areas:** Reliability, Maintainability
- **Runs:** By default, when the target applies
- **Network:** Only the target itself

## Run only this auditor

```sh
bunx @openaudit/cli . --only code.phpstan
```

Wraps phpstan. When it isn't installed, the auditor is skipped with an install hint and the rest of the audit runs.

## More reliability auditors

- [TypeScript type-check (tsc)](https://openaudit.se/auditors/code.typecheck/) (`code.typecheck`)
- [Ruff Python lints](https://openaudit.se/auditors/code.ruff/) (`code.ruff`)
- [staticcheck Go lints](https://openaudit.se/auditors/code.staticcheck/) (`code.staticcheck`)
- [ShellCheck](https://openaudit.se/auditors/code.shellcheck/) (`code.shellcheck`)
- [Rust clippy lints](https://openaudit.se/auditors/code.clippy/) (`code.clippy`)
- [mypy type check](https://openaudit.se/auditors/code.mypy/) (`code.mypy`)
- [golangci-lint](https://openaudit.se/auditors/code.golangci-lint/) (`code.golangci-lint`)
- [PMD Java analysis](https://openaudit.se/auditors/code.pmd/) (`code.pmd`)
