---
title: pun analyse
description: Find bugs. Never edits files.
---

Find bugs with types, like PHPStan. It never edits files. Also runs as `pun analyze`.

## Usage

```bash
pun analyse [paths] [options]
```

```bash
pun analyse                       # whole project
pun analyse app tests             # some folders
pun analyse --generate-baseline   # accept current errors
```

## Options

| Option | Description |
| --- | --- |
| `--generate-baseline [<file>]` | Save every current error to a baseline and exit 0. |
| `--config <path>` | Use this `pun.toml`. |
| `--format=<fmt>` | Report as `raw`, `json`, `checkstyle`, `junit`, `gitlab`, `github` or `teamcity`. Alias: `--error-format`. |
| `--concise` | One line per error. |
| `--max-processes=<n>` | Limit threads. Default: one per core. |
| `--color=<when>` | `auto`, `always` or `never`. |
| `-v` | Add identifiers to `raw` output. |
| `-q` | Print nothing. The exit code gives the result. |

## What happens

- Reads the `[analyse]` preset and rules from `pun.toml`.
- Checks the files in `[analyse] paths`, or `[files] paths`, or the whole project.
- Reads `vendor/` for classes and functions, but never reports on it.
- Hides errors listed in the baseline (`[analyse] baseline`).
- With the `laravel` extension on, also runs Larastan's checks.
- If a file has a syntax error, reports only syntax errors.

```toml pun.toml
[analyse]
preset = "strict"
paths = ["app", "tests"]
baseline = "pun-baseline.toml"

[analyse.rules]
"types/missing-return-type" = "off"
```

To ignore one line, add `// @pun-ignore <rule> -- <reason>`. See [ignore comments](/docs/configuration/ignore-comments). The [rule reference](/docs/rules/analyse) lists every check.

## Limitations

Pun doesn't run every PHPStan or Larastan check yet. The [rule reference](/docs/rules/analyse) marks the missing ones as Planned.

**Config**

- `pun.toml` takes a preset, not a numeric PHPStan level. Use `preset = "phpstan/level_<n>"` for PHPStan's exact rule set. Pun still differs from PHPStan on some cases at each level, and six rules aren't ported yet.
- `checkFunctionArgumentTypes`, `checkArgumentsPassedByReference` and `checkThisOnly` can't be set on their own. `pun migrate` reports them as unsupported.
- PHPStan baselines are not read. Make a new one with `--generate-baseline`.
- No `table` or `prettyJson` output formats.
- `json` marks errors as `"fixable"`, but Pun doesn't fix them.

**Laravel**

- Larastan rules are off when the lock pins a Laravel version that Larastan 3 doesn't support. Larastan 3 supports 11.44.2+, 12.4.1+ and 13.x.
- `enableMigrationCache` is not supported. Schema dumps are read with Larastan's MySQL-style parser.
- Pun doesn't run PHP, so it finds macros by reading `X::macro()` and `X::mixin()` calls in your bootstrap files, `app/Providers`, Laravel and package service providers, and analysed files.
- It misses macros with computed names, mixins that aren't `new ClassName()`, mixin classes it can't find, and macros registered by other vendor files.
- A closure macro without a native return type is `mixed`.
- Class aliases from service providers, dynamic config, `AliasLoader` calls, custom bootstrap, config, cache or vendor paths, and real-time `Facades\...` classes are not supported.
- Method forwarding to container services through an alias is not supported.

**Includes**

- Include checks don't support bzip2, OpenSSL signatures, PHAR aliases and mounts, or runtime stream wrappers.
- A `zip://` include is always reported as missing.

## Exit codes

| Code | Meaning |
| --- | --- |
| 0 | No errors. |
| 1 | Errors. |
| 2 | Pun could not run, or every rule is off. |
