laravel/surveyor
Beta Laravel tool for mostly static analysis of PHP/Laravel apps. Parses files/classes to extract rich metadata (classes, methods, properties, types) and can inspect models and container bindings for extra detail. Returns structured results for other tools.
Enhanced Eloquent Query Analysis:
User::where('active', true)->limit(10)), enabling tools to:
active users and limits to 10 records").where() clause could use a database index").limit() is missing an offset() for pagination").User::whereHas('posts')->get() now accurately resolves to Collection<User>), supporting:
whereHas() relationships).User models with posts eager-loaded").Hardened Class and Interface Analysis:
RepositoryInterface vs. UserRepository), enabling:
RepositoryInterface but lacks find()").ShouldRegister interface").class as a method name), improving:
use HasApiTokens; in Laravel Sanctum).Build vs. Buy for Laravel-Specific Tooling:
whereHas() query could be rewritten for performance").has() clause is deprecated in Laravel 11").Collection<User> after get()").Roadmap for Developer Experience (DX):
where() chain to a query scope").join() is unnecessary—use with() instead").Serializable but lacks serialize()").whereRaw() uses reserved keywords").Use Cases:
User with 3 posts").ServiceProvider, Macroable).Adopt if:
RepositoryInterface or ShouldRegister).Look elsewhere if:
phpstan or psalm).xdebug, or tntsearch).phpmetrics).*"Surveyor just got smarter about Laravel’s database layer, which unlocks new ways to automate and optimize Eloquent queries. The latest update (v0.2.4) fixes critical gaps in:
where()->limit()->get()) and propagates generic types (e.g., Collection<User>), enabling tools like:
whereHas() query could be rewritten for performance").with()").ShouldRegister"), reducing technical debt in packages.class as a method name) and deprecated Eloquent patterns.
Why this matters: This release shows Surveyor is actively closing Laravel-specific gaps—not just generic PHP parsing. It’s still Beta, but the fixes (e.g., Eloquent generics, builder resolution) make it a stronger candidate for production tooling like query optimizers or IDE plugins. Think of it as Laravel’s answer to static analysis for the database layer."**"Surveyor v0.2.4 fixes four key Eloquent and type-resolution issues:
where()->limit()->get() now resolve correctly, enabling accurate query analysis.Collection<User> types now propagate through builder chains (e.g., User::whereHas('posts')->get()).RepositoryInterface), useful for package validation.class) are resolved properly.
Why this matters:ShouldRegister).*"Surveyor just got better at understanding Eloquent queries and Laravel interfaces. For example:
User::where('active')->limit(10) now resolve correctly.Collection<User> types propagate through whereHas() and other methods.RepositoryInterface but lacks methods.class or abstract.
This means tools you build (e.g., query explainers, IDE features) will now work correctly with Eloquent. Try it if you’ve ever:where()->orWhere()->with() chains.How can I help you explore Laravel packages today?