Skip to content
janalisPublic

Latest commit

 

History

1,124 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

custos

custos

Fast PHP inspector and fixer.
Rules with quick-fixes · one static binary · CLI, CI, LSP and MCP

CI Docs Latest release Packagist MIT license

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.6), 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.86 s 391 MB
custos analyse analyzer 5.18 s 742 MB
Phan analyzer 15.4 s 1.7 GB
PHPStan analyzer 23.1 s 1.6 GB
Psalm analyzer 58.4 s 2.4 GB
Mago lint linter 0.24 s 197 MB
PHP_CodeSniffer linter 7.17 s 124 MB
custos fix fixer 4.48 s 654 MB
PHP-CS-Fixer fixer 9.14 s 181 MB
Rector fixer 26.4 s 3.4 GB
Mago format formatter 0.20 s 256 MB
custos format formatter 0.65 s 99 MB
PHP-CS-Fixer (layout) formatter 12.4 s 181 MB
Laravel Pint formatter 29.4 s 74 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.

Releases

Packages

Contributors

Languages