Getting Started
Install the extension as a development dependency, register it with PHPStan,
and analyse a validated() call. Full configuration is in
Configuration.
Installation
Requires PHP 8.1. Supported on PHP 8.1 through 8.5, PHPStan 2.1.5 or later, and Laravel 10 through 13.
composer require --dev jbboehr/phpstan-laravel-validation
If you also install
phpstan/extension-installer,
the extension is registered automatically.
Otherwise include it from phpstan.neon:
includes:
- vendor/jbboehr/phpstan-laravel-validation/extension.neon
First analysis
$validated = \Illuminate\Support\Facades\Validator::make($input, [
'name' => 'required|string',
'age' => 'integer',
])->validated();
\PHPStan\dumpType($validated);
// array{name: string, age?: float|int|string|Stringable|true}
name is required. age is optional, and its value type includes every
native representation Laravel can accept and preserve for integer.
The same rule-set inference applies to factory make() / validate(),
Request::validate(), and controller validate(). See
Supported Entry Points.
Common first options
Most projects can start with the defaults. These are the options most projects are likely to consider first:
| Option | Default | When to change it |
|---|---|---|
laravelVersion | auto | PHPStan’s working directory is not the Composer project that owns Laravel |
assumeHttpInputNormalization | false | Request validation always runs after Laravel’s default trim/empty-string middleware |
formRequests.enabled | false | You want experimental FormRequest::validated() inference |
parameters:
phpstanLaravelValidation:
laravelVersion: auto
Details, diagnostics, and the remaining options are in Configuration.
Compatibility
- PHP 8.1 through 8.5
- PHPStan 2.1.5 or later
- Laravel 10 through 13
Version-specific inference boundaries are listed in Laravel Version Behavior.