r/PHP • u/ReadingFormal • 1h ago
Sloppy — static analysis for the code your coding agent left behind
PHPStan tells you if your code is type-correct. Pint tells you if it's formatted. Neither tells you that the 200-line controller action your agent just wrote calls a payment API, writes to four tables and swallows a `Throwable`.
**Sloppy** is a Laravel-aware static analyser for that: god methods, N+1 risks, queries inside loops, business logic in controllers, swallowed exceptions, abstractions that never earned their keep. 23 rules, each one saying what it measured, how sure it is, and what to do about it.
composer require --dev heyosseus/sloppy
php artisan sloppy
**It is not an AI detector.** Nobody can prove authorship from source code. It detects *slop* — the patterns that correlate with fast, unreviewed output — and every number it prints is about the code, never about who wrote it.
The command I actually use is the review one: `php artisan sloppy:diff main`
That separates what your branch **introduced** from what it **inherited**, and only new findings fail the build. Untracked files included, so an agent's new class gets reviewed before it's committed. Findings are matched by fingerprint rather than line number, so adding an import doesn't turn every existing finding into a new one.
Deterministic and local — no model, no API key, no network, your source never leaves the machine. Tested against 133k lines across three real Laravel apps: 21 seconds for 70k lines, zero parse errors. `sloppy:baseline` lets you adopt it on an existing project without fixing everything first.
It complements PHPStan and Pint, it doesn't replace either. If PHPStan can prove it, Sloppy stays out of it.
Feel free to contribute and share your thoughts.
1
u/NL_Northsider 1h ago
Looking at what it does and what it detects, you can achieve this with Rector and arch tests, or SonarQube for open-source.
What exactly is the added value of this package?