janalis / custos
Fast PHP inspector and fixer with quick-fixes, shipped as a prebuilt binary.
Requires
- php: >=7.4
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
custos
Fast PHP inspector and fixer.
Rules with quick-fixes · one static binary · CLI, CI, LSP and MCP
Documentation · Getting started · Rules · Editors · AI agents
custos finds probable bugs, performance and security issues, needless
complexity and outdated constructs in PHP code (PHP 5.3 to 8.5), and fixes
many of them for you. It also formats code, following PER, PSR-12, Symfony,
Laravel or Drupal style presets that .editorconfig and custos.json can
adjust. It is written in Go with its own PHP parser and type
inference, so it needs no PHP runtime. It runs from the command line, in CI,
in editors as a language server, and with AI agents through MCP.
The catalogue mixes rules modeled on Php Inspections (EA Extended), whose
existing @noinspection XxxInspection comments keep working, and native rules
designed for custos. custos is an independent clean-room implementation (see
NOTICE).
Install
brew install janalis/tap/custos # macOS / Linux composer require --dev janalis/custos # per project → vendor/bin/custos
Archives and bare binaries for Linux, macOS and Windows (amd64/arm64) are on the releases page. See Installation for details and building from source.
Quick start
custos analyse # report problems in the project custos fix --dry-run --diff src # preview quick-fixes custos fix src # apply them custos format --check # check the layout (custos format to apply) custos explain OneTimeUseVariables # what a rule does, its options custos mcp --root /path/to/project # MCP server for AI agents
src/Invoice.php:3:5: warning: Variable $total is used only once; inline its value. [OneTimeUseVariables] (fixable)
src/Invoice.php:7:6: error: Restrict the classes unserialize() may create via its second argument. [UnserializeExploits]
More in the guide: command line, baseline for legacy code, formatting, CI recipes, editor setup, MCP setup and the rule reference.
For Claude Code, one plugin adds the MCP tools and reports findings after each edit:
claude plugin install custos --marketplace janalis/custos
How it compares
custos reports and fixes problems, and formats code.
Speed on laravel/framework v13.43.0 (1,757 PHP files), 4 cores, median of 3 runs:
| Tool | Kind | Time | Peak memory |
|---|---|---|---|
| Mago analyze | analyzer | 0.81 s | 387 MB |
| custos analyse | analyzer | 5.11 s | 729 MB |
| Phan | analyzer | 14.0 s | 1.7 GB |
| PHPStan | analyzer | 21.5 s | 1.7 GB |
| Psalm | analyzer | 56.1 s | 2.5 GB |
| Mago lint | linter | 0.23 s | 212 MB |
| PHP_CodeSniffer | linter | 6.61 s | 129 MB |
| custos fix | fixer | 4.28 s | 625 MB |
| PHP-CS-Fixer | fixer | 8.75 s | 180 MB |
| Rector | fixer | 25.5 s | 3.4 GB |
| Mago format | formatter | 0.21 s | 230 MB |
| custos format | formatter | 0.63 s | 107 MB |
| PHP-CS-Fixer (layout) | formatter | 12.1 s | 181 MB |
| Laravel Pint | formatter | 30.7 s | 75 MB |
Features (✓ yes, ◐ partial, — no):
| Feature | custos | PHPStan | Psalm | Phan | Mago | PHP_CodeSniffer | PHP-CS-Fixer | Laravel Pint | Rector |
|---|---|---|---|---|---|---|---|---|---|
| Written in | Go | PHP | PHP | PHP | Rust | PHP | PHP | PHP | PHP |
| Runs without PHP | ✓ | — | — | — | ✓ | — | — | — | — |
| Type checking | ✓ | ✓ | ✓ | ✓ | ✓ | — | — | — | — |
| Taint analysis | ✓ | — | ✓ | — | ◐ | — | — | — | — |
| Automatic fixes | ✓ | ◐ | ✓ | ◐ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Formatter | ✓ | — | — | — | ✓ | ◐ | ✓ | ✓ | — |
| Line wrapping | ✓ | — | — | — | ✓ | — | — | — | — |
| Formatting presets | ✓ | — | — | — | ✓ | ✓ | ✓ | ✓ | — |
| EditorConfig | ✓ | — | — | — | — | — | — | — | — |
| Range formatting (LSP) | ✓ | — | — | — | — | — | — | — | — |
| Language server | ✓ | — | ✓ | ✓ | — | — | — | — | — |
| MCP server for AI agents | ✓ | — | — | — | — | — | — | — | — |
| Baseline | ✓ | ✓ | ✓ | ✓ | ✓ | — | — | — | — |
| Custom rules | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | — | ✓ |
| SARIF output | ✓ | — | ✓ | — | ✓ | — | — | — | — |
Other projects, versions, finding counts and the sources of every feature are on the benchmark page.
Configuration
An optional custos.json at the project root pins the PHP version, chooses
paths and turns rules on or off; see
Getting started
for an example and
Configuration for
every key.
Contributing
Contributions are welcome: bug reports with a PHP snippet, false positives, fixes. Read CONTRIBUTING.md and the contributor guide. Please note the clean-room rule: no code or text from the upstream plugin may enter this repository.
make build # → bin/custos make verify # architecture + lint + tests + fixtures + 100 % coverage + clean-room scan
License
MIT. Builtin symbol data from JetBrains phpstorm-stubs (Apache-2.0). See NOTICE.
