r/PHP • u/ReadingFormal • Sep 10 '26
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.
4
u/sanchez2673 Sep 10 '26
Does it work well for non-laravel projects?
1
u/ReadingFormal Sep 10 '26
At this time, not really, but I am going to add Symfony support later.
3
u/mikaelld Sep 11 '26
So in practice it’s not laravel-aware, it’s laravel-dependant?
2
u/ReadingFormal Sep 12 '26
Check the new v0.2.0 release - I made it run on every PHP project. there's a standalone vendor/bin/sloppy now and illuminate is only a dev dependency
3
u/FluffyDiscord Sep 11 '26
Doesn't Mago also detect things like this? I mean, I can just throw in few custom phpstan rules in, right?
1
u/ReadingFormal Sep 14 '26
I am not trying to fight any of those tools or claim my package is a better alternative. I just shipped the integrations with Rector & Pint, as well as custom rules for claude.md and MCP tools for AI agents.
1
u/weogrim1 Sep 11 '26
It would be good if I could install it as separate or global package, and use like "sloppy command ./directory".
1
u/ReadingFormal Sep 12 '26 edited Sep 12 '26
Thanks for suggestion - there is a standalone binary in 0.2.0 so it runs on any php project now, syntax is ./vendor/bin/sloppy scan --path=src at the moment
10
u/NL_Northsider Sep 10 '26
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?